zoukankan      html  css  js  c++  java
  • golang时间

    //获取本地location
    	toBeCharge := "2015-01-01 00:00:00"                             //待转化为时间戳的字符串 注意 这里的小时和分钟还要秒必须写 因为是跟着模板走的 修改模板的话也可以不写
    	timeLayout := "2006-01-02 15:04:05"                             //转化所需模板
    	loc, _ := time.LoadLocation("Local")                            //重要:获取时区
    	theTime, _ := time.ParseInLocation(timeLayout, toBeCharge, loc) //使用模板在对应时区转化为time.time类型
    	sr := theTime.Unix()                                            //转化为时间戳 类型是int64
    	fmt.Println(theTime)                                            //打印输出theTime 2015-01-01 15:15:00 +0800 CST
    	fmt.Println(sr)                                                 //打印输出时间戳 1420041600
    
    	//时间戳转日期
    	dataTimeStr := time.Unix(sr, 0).Format(timeLayout) //设置时间戳 使用模板格式化为日期字符串
    	fmt.Println(dataTimeStr)  
  • 相关阅读:
    QuartzQuartz定时任务
    jdbc模糊查询、分页查询、联合查询
    PreparedStatement
    web服务器简述
    JDBC基本操作
    RMI
    Http编程
    2020毕业季业务开发宝典
    程序设计流程图
    系统概要框图
  • 原文地址:https://www.cnblogs.com/zhangym/p/5730324.html
Copyright © 2011-2022 走看看