@@ -5,22 +5,27 @@ description: Learn about converting between DateTime and Unix/Epoch time formats
5
5
sidebar :
6
6
label : " Epoch Time"
7
7
order : 3
8
+ badge :
9
+ text : deprecated
10
+ variant : note
8
11
redirect_from :
9
12
- /foss/identitymodel/utils/epoch_time/
10
13
---
11
14
12
- ::: note
15
+ ::: note [ Deprecation notice ]
13
16
Starting with .NET Framework 4.6 and .NET Core 1.0 this functionality is
14
17
built-in via
15
- [ DateTimeOffset.FromUnixTimeSeconds] ( https://docs.microsoft.com/en-us/dotnet/api/system.datetimeoffset.fromunixtimeseconds )
18
+ [ ` DateTimeOffset.FromUnixTimeSeconds ` ] ( https://docs.microsoft.com/en-us/dotnet/api/system.datetimeoffset.fromunixtimeseconds )
16
19
and
17
- [ DateTimeOffset.ToUnixTimeSeconds] ( https://docs.microsoft.com/en-us/dotnet/api/system.datetimeoffset.tounixtimeseconds ) .
20
+ [ ` DateTimeOffset.ToUnixTimeSeconds ` ] ( https://docs.microsoft.com/en-us/dotnet/api/system.datetimeoffset.tounixtimeseconds ) .
21
+
22
+ The ` DateTimeExtensions ` will be removed from Duende IdentityModel in the future.
18
23
:::
19
24
20
25
JSON Web Token (JWT) tokens use so-called [ Epoch or Unix time] ( https://en.wikipedia.org/wiki/Unix_time ) to represent
21
26
date/times, which is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT).
22
27
23
- ## DateTimeOffset To Epoch Time
28
+ ## DateTimeOffset To Epoch Time : badge [ Obsolete ]
24
29
25
30
In .NET, you can convert ` DateTimeOffset ` to Unix time via the two methods of ` ToUnixTimeSeconds ` and
26
31
` ToUnixTimeMilliseconds ` :
@@ -31,7 +36,7 @@ var seconds = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
31
36
var milliseconds = DateTimeOffset .UtcNow .ToUnixTimeMilliseconds ();
32
37
```
33
38
34
- ## DateTime To Epoch Time : badge [ obsolete ]
39
+ ## DateTime To Epoch Time : badge [ Obsolete ]
35
40
36
41
IdentityModel contains extensions methods for ` DateTime ` to convert
37
42
to/from Unix time:
0 commit comments