-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnow.go
More file actions
37 lines (30 loc) · 1010 Bytes
/
now.go
File metadata and controls
37 lines (30 loc) · 1010 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package timezone
import "time"
// format layout as 2006-01-02 15:04:05
func UTCSecond() string {
return time.Now().In(time.FixedZone(ZoneUTC, 0)).Format(LayoutSecond)
}
// format layout as 2006-01-02 15:04:05.999999
func UTCMicro() string {
return time.Now().In(time.FixedZone(ZoneUTC, 0)).Format(LayoutMicro)
}
// format layout as 2006-01-02 15:04:05
// get location time format by SetZoneByName() or SetZoneFix()
func Second() string {
return time.Now().In(zoneLocal).Format(LayoutSecond)
}
// format layout as 2006-01-02 15:04:05.999999
// get location time format by SetZoneByName() or SetZoneFix()
func Micro() string {
return time.Now().In(zoneLocal).Format(LayoutMicro)
}
// Unix returns t as a Unix time, the number of seconds
// elapsed since January 1, 1970 UTC.
func TimestampSecond() int64 {
return time.Now().Unix()
}
// UnixNano returns t as a Unix time, the number of nanoseconds
// elapsed since January 1, 1970 UTC.
func TimestampUnixNano() int64 {
return time.Now().UnixNano()
}