Unix Timestamp in C#
Look up the current epoch time and convert between Unix seconds and UTC dates in C#.
Get the current timestamp
using System;
Console.WriteLine(DateTimeOffset.UtcNow.ToUnixTimeSeconds());Timestamp to date
using System;
Console.WriteLine(DateTimeOffset.FromUnixTimeSeconds(1_700_000_000).ToString("O"));Date to timestamp
using System;
Console.WriteLine(DateTimeOffset.Parse("2023-11-14T22:13:20Z").ToUnixTimeSeconds());Open 1700000000 in the converter
Current Unix time
Seconds—
Milliseconds—
- UTC
- —
- My time zone
- —
Free to use. Your input stays in this browser.
How to use it
- Copy the current-time example into your C# environment to read Unix seconds.
- Run the second example to display 1700000000 as a UTC date.
- Run the last example to convert that date back into seconds.
DateTimeOffset represents a time together with its UTC offset. The O format preserves that offset. Use the UnixTimeMilliseconds methods when the source sends milliseconds.