time _ golang
Go's offers extensive support for times and durations; here are some example
package main import ( "fmt" "time" ) func main() { p := fmt.Println now := time.Now() p(now) then := time.Date( 2009, 11, 17, 20, 34, 58, 651387237, time.UTC) p(then) p(then.Year()) p(then.Month()) p(then.Day()) p(then.Hour()) p(then.Minute()) p(then.Second()) p(then.Nanosecond()) p(then.Location()) p(then.Before(now)) p(then.After(now)) p(then.Equal(now)) diff := now.Sub(then) p(diff) p(diff.Hours()) p(diff.Minutes()) p(diff.Seconds()) p(diff.Nanoseconds()) p(then.Add(diff)) p(then.Add(-diff)) }
2015-03-25 14:12:14.302895576 +0800 CST 2009-11-17 20:34:58.651387237 +0000 UTC 2009 November 17 20 34 58 651387237 UTC true false false 46881h37m15.651508339s 46881.62101430787 2.8128972608584724e+06 1.6877383565150833e+08 168773835651508339 2015-03-25 06:12:14.302895576 +0000 UTC 2004-07-13 10:57:42.999878898 +0000 UTC
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。