What is the equivalent of Java\'s System.currentTimeMillis()
in C#?
We could also get a little fancy and do it as an extension method, so that it hangs off the DateTime class:
public static class DateTimeExtensions
{
private static DateTime Jan1st1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
public static long currentTimeMillis(this DateTime d)
{
return (long) ((DateTime.UtcNow - Jan1st1970).TotalMilliseconds);
}
}