Skip to content

Instantly share code, notes, and snippets.

@bennotti
Forked from AntonyKapustin/TimeUtils.cs
Created March 15, 2022 22:47
Show Gist options
  • Save bennotti/dedc825eee0b62603794e95e9f664016 to your computer and use it in GitHub Desktop.
Save bennotti/dedc825eee0b62603794e95e9f664016 to your computer and use it in GitHub Desktop.
CurrentTimeMillis() in C#
using System;
public class TimeUtils {
private static readonly DateTime Jan1st1970 = new DateTime
(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
public static long CurrentTimeMillis()
{
return (long) (DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment