unix.md (1081B)
1 ---
2 title: .Unix
3 description: Converts a time.Time value to the number of seconds elapsed since the Unix epoch, excluding leap seconds. The Unix epoch is 00:00:00 UTC on 1 January 1970.
4 date: 2017-02-01
5 keywords: [dates,time]
6 categories: [functions]
7 menu:
8 docs:
9 parent: "functions"
10 signature: [".Unix",".UnixMilli",".UnixMicro",".UnixNano"]
11 relatedfuncs: [Format,dateFormat,now,time]
12 ---
13
14 The `Milli`, `Micro`, and `Nano` variants return the number of milliseconds, microseconds, and nanoseconds (respectively) elapsed since the Unix epoch.
15
16 ```go-html-template
17 .Date.Unix --> 1637259694
18 .ExpiryDate.Unix --> 1672559999
19 .Lastmod.Unix --> 1637361786
20 .PublishDate.Unix --> 1637421261
21
22 ("1970-01-01T00:00:00-00:00" | time.AsTime).Unix --> 0
23 ("1970-01-01T00:00:42-00:00" | time.AsTime).Unix --> 42
24 ("1970-04-11T01:48:29-08:00" | time.AsTime).Unix --> 8675309
25 ("2026-05-02T20:09:31-07:00" | time.AsTime).Unix --> 1777777771
26
27 now.Unix --> 1637447841
28 now.UnixMilli --> 1637447841347
29 now.UnixMicro --> 1637447841347378
30 now.UnixNano --> 1637447841347378799
31 ```