博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
go语言日期时间格式化
阅读量:4693 次
发布时间:2019-06-09

本文共 1652 字,大约阅读时间需要 5 分钟。

原文: 

 

package main  import (    "fmt"    "time")func main() {      currentTime := time.Now()      fmt.Println("Current Time in String: ", currentTime.String())          fmt.Println("MM-DD-YYYY : ", currentTime.Format("01-02-2006"))          fmt.Println("YYYY-MM-DD : ", currentTime.Format("2006-01-02"))          fmt.Println("YYYY.MM.DD : ", currentTime.Format("2006.01.02 15:04:05"))          fmt.Println("YYYY#MM#DD {Special Character} : ", currentTime.Format("2006#01#02"))          fmt.Println("YYYY-MM-DD hh:mm:ss : ", currentTime.Format("2006-01-02 15:04:05"))              fmt.Println("Time with MicroSeconds: ", currentTime.Format("2006-01-02 15:04:05.000000"))          fmt.Println("Time with NanoSeconds: ", currentTime.Format("2006-01-02 15:04:05.000000000"))          fmt.Println("ShortNum Month : ", currentTime.Format("2006-1-02"))          fmt.Println("LongMonth : ", currentTime.Format("2006-January-02"))          fmt.Println("ShortMonth : ", currentTime.Format("2006-Jan-02"))          fmt.Println("ShortYear : ", currentTime.Format("06-Jan-02"))          fmt.Println("LongWeekDay : ", currentTime.Format("2006-01-02 15:04:05 Monday"))          fmt.Println("ShortWeek Day : ", currentTime.Format("2006-01-02 Mon"))             fmt.Println("ShortDay : ", currentTime.Format("Mon 2006-01-2"))          fmt.Println("Short Hour Minute Second: ", currentTime.Format("2006-01-02 3:4:5"))             fmt.Println("Short Hour Minute Second: ", currentTime.Format("2006-01-02 3:4:5 PM"))              fmt.Println("Short Hour Minute Second: ", currentTime.Format("2006-01-02 3:4:5 pm"))    }

  

转载于:https://www.cnblogs.com/oxspirt/p/11006492.html

你可能感兴趣的文章
adb shell am 的用法
查看>>
实现自动点击
查看>>
MVP开发模式的理解
查看>>
Unity多开的方法
查看>>
深入PHP内核之数组
查看>>
File类中的list()和listFiles()方法
查看>>
我的VS CODE插件配置 主要针对.NET和前端插件配置
查看>>
关于js中的事件
查看>>
一致性哈希算法运用到分布式
查看>>
决策树和随机森林->信息熵和条件熵
查看>>
iOS10 UI教程视图和子视图的可见性
查看>>
Maven学习笔记
查看>>
FindChildControl与FindComponent
查看>>
1、简述在java网络编程中,服务端程序与客户端程序的具体开发步骤?
查看>>
C# Web版报表
查看>>
中国城市json
查看>>
LeetCode OJ 238. Product of Array Except Self 解题报告
查看>>
使用外网访问阿里云服务器ZooKeeper
查看>>
Java代码检查工具
查看>>
深入了解VC++编译器【转】
查看>>