DateTimeOffset.FromUnixTimeMilliseconds Method (Int64)

.NET Framework (current version)
 

Converts a Unix time expressed as the number of milliseconds that have elapsed since 1970-01-01T00:00:00Z to a DateTimeOffset value.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

public static DateTimeOffset FromUnixTimeMilliseconds(
	long milliseconds
)

Parameters

milliseconds
Type: System.Int64

A Unix time, expressed as the number of milliseconds that have elapsed since 1970-01-01T00:00:00Z (January 1, 1970, at 12:00 AM UTC). For Unix times before this date, its value is negative.

Return Value

Type: System.DateTimeOffset

A date and time value that represents the same moment in time as the Unix time.

Exception Condition
ArgumentOutOfRangeException

milliseconds is less than -62,135,596,800,000.

-or-

milliseconds is greater than 253,402,300,799,999.

The Offset property value of the returned DateTimeOffset instance is TimeSpan.Zero, which represents Coordinated Universal Time. You can convert it to the time in a specific time zone by calling the TimeZoneInfo.ConvertTime(DateTimeOffset, TimeZoneInfo) method.

Universal Windows Platform
Available since 10
.NET Framework
Available since 4.6
Return to top
Show: