For Developers
How to get the current timestamp, convert it to a date, and convert a date back to a timestamp in C# — plus the specific mistake that trips up C# code more than any other.
DateTimeOffset.UtcNow.ToUnixTimeSeconds()
DateTimeOffset.FromUnixTimeSeconds(1750000000)
DateTimeOffset.Parse("2025-06-15T12:00:00Z").ToUnixTimeSeconds()
Use DateTimeOffset, not the older DateTime, for anything involving Unix timestamps — DateTime has a Kind property (Local/Utc/Unspecified) that's a frequent source of the exact same naive-vs-aware confusion Python has, and DateTimeOffset sidesteps it by always carrying an explicit offset.
Paste it into the Timestamp ⇄ Date Converter to check it instantly, in any timezone, without writing any code. Working across several languages on the same project? The full Epoch Time in Programming Languages guide has all of them side by side for quick comparison.
Related
Every language's snippets side by side, for quick comparison.
Convert any timestamp instantly, no code required.
See one date rendered in ISO, US, EU, and more, at once.