DateTimeExtensionsToUnixMilliseconds Method

Gets the time elapsed since the Unix Epoch time (1970-01-01T00:00Z) in milliseconds, not counting leap seconds.

Definition

Namespace: KGySoft.CoreLibraries
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 7.0.0-rc.1
C#
public static long ToUnixMilliseconds(
	this DateTime value
)

Parameters

value  DateTime
A DateTime value to get the Unix time from.

Return Value

Int64
The number of milliseconds that have elapsed since 1970-01-01T00:00Z.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type DateTime. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

This method is similar to DateTimeOffset.ToUnixTimeMilliseconds but is available even below .NET Framework 4.6.

If value is a Local time, then its Kind is converted to UTC first.

This method returns a negative value for times before 1970-01-01T00:00Z.

See Also