time package | Golang get time
![time package](https://i.imgur.com/axBPWDg.jpg)
ADurationrepresentstheelapsedtimebetweentwoinstantsasanint64nanosecondcount.Therepresentationlimitsthelargestrepresentabledurationtoapproximately290years.packagemainimport("fmt""time")funcexpensiveCall(){}funcmain(){t0:=time.Now()expensiveCall()t1:=time.Now()fmt.Printf("Thecalltook%vtorun.",t1.Sub(t0))}Output:ParseDurationparsesadurationstring.Adurationstringisapossiblysignedsequenceofdecimalnumbers,eachwithoptionalfractionandaunitsuffix,suchas"300ms","-1.5h"or"2h45m".Validtimeunitsare"ns","...
A Duration represents the elapsed time between two instants as an int64 nanosecond count. The representation limits the largest representable duration to approximately 290 years.
package main import ( "fmt" "time" ) func expensiveCall() {} func main() { t0 := time.Now() expensiveCall() t1 := time.Now() fmt.Printf("The call took %v to run. ", t1.Sub(t0)) } Output:ParseDuration parses a duration string. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
package main import ( "fmt" "time" ) func main() { hours, _ := time.ParseDuration("10h") complex, _ := time.ParseDuration("1h10m10s") micro, _ := time.ParseDuration("1µs") // The package also accepts the incorrect but common prefix u for micro. micro2, _ := time.ParseDu...取得本站獨家住宿推薦 15%OFF 訂房優惠
本站住宿推薦 20%OFF 訂房優惠,親子優惠,住宿折扣,限時回饋,平日促銷
Get current date and time in various format in golang | Golang get time
Get current time as formatted string in Go? | Golang get time
Get Year, Month, Day | Golang get time
Golang Get current Date and Time in EST | Golang get time
How to Get Current Date and Time in Golang | Golang get time
How to Get Current Date and Time in Various Format in Golang? | Golang get time
How to Get Current time in Golang? | Golang get time
How to get current timestamp · YourBasic Go | Golang get time
time package | Golang get time
[Golang] 關於Golang Time 的處理 | Golang get time
![](https://i.imgur.com/axBPWDg.jpg)