惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

G
GRAHAM CLULEY
T
Tenable Blog
Know Your Adversary
Know Your Adversary
C
CXSECURITY Database RSS Feed - CXSecurity.com
P
Privacy International News Feed
S
Security Affairs
NISL@THU
NISL@THU
O
OpenAI News
Attack and Defense Labs
Attack and Defense Labs
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Hacker News: Ask HN
Hacker News: Ask HN
Webroot Blog
Webroot Blog
Schneier on Security
Schneier on Security
S
SegmentFault 最新的问题
S
Schneier on Security
G
Google Developers Blog
V
V2EX
C
Check Point Blog
U
Unit 42
Google DeepMind News
Google DeepMind News
T
Threatpost
阮一峰的网络日志
阮一峰的网络日志
T
The Exploit Database - CXSecurity.com
Recent Announcements
Recent Announcements
M
MIT News - Artificial intelligence
S
Secure Thoughts
博客园 - 司徒正美
Recorded Future
Recorded Future
P
Proofpoint News Feed
Spread Privacy
Spread Privacy
K
Kaspersky official blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
AI
AI
博客园 - 聂微东
N
News and Events Feed by Topic
SecWiki News
SecWiki News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
Vulnerabilities – Threatpost
P
Palo Alto Networks Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Engineering at Meta
Engineering at Meta
Recent Commits to openclaw:main
Recent Commits to openclaw:main
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
酷 壳 – CoolShell
酷 壳 – CoolShell
WordPress大学
WordPress大学
The Hacker News
The Hacker News
The Last Watchdog
The Last Watchdog
Project Zero
Project Zero
W
WeLiveSecurity
博客园 - Franky

博客园 - forrestsun

问题整理 weedfs getsockopt: connection timed out 利用cubieboard设置samba打印服务器 CubieTruck上安装mjpg_streamer devexpress bandgridview使用总结(14.2) WeedFS0.6.8-引用库列表 NSQ的消息订阅发布测试 WeedFS问题收集 WeedFS依赖库 0.6.1 golang 前置补0 MongoDB-MMS使用总结 golang 格式化时间为字符串 mgo-后续测试(指定字段,获取id) mgo中DBRef-数据查询测试 mgo中DBRef-数据添加测试 weed-fs 基础测试 weed-fs 压力测试 weed-fs参数列表 mgo like的两种写法
格式化字符串为时间学习总结
forrestsun · 2014-01-26 · via 博客园 - forrestsun
package main

import (
	"fmt"
	"time"
)

func main() {
	test, err := time.Parse("2006-01-02", "2013-01-12")
	if err != nil {
		panic(err)
	}

	fmt.Println(test)
}
[ `run` | done: 4.533945ms ]
2013-01-12 00:00:00 +0000 UTC

其中time.parse格式改变后,未发生变化

test, err := time.Parse("2006/01/02", "2013/01/12")
[ `run` | done: 1.499388ms ]
2013-01-12 00:00:00 +0000 UTC

再换,结果未变:

test, err := time.Parse("01/02/2006", "01/12/2013")
[ `run` | done: 1.471152ms ]
2013-01-12 00:00:00 +0000 UTC

截取取小时:

test, err := time.Parse("2006-01-02 15", "2013-05-13 13")

截取到分钟:

test, err := time.Parse("2006-01-02 15:04", "2013-05-13 10:30")
[ `run` | done: 1.414665ms ]
2013-05-13 10:30:00 +0000 UTC

截取到秒:

 
test, err := time.Parse("2006-01-02 15:04:05", "2013-05-13 10:30:03")
[ `run` | done: 1.554238ms ]
2013-05-13 10:30:03 +0000 UTC

随着截取位置的不同,通过补零设置