Class UnixTimestamp
Utility class to assist with Unix timestamp conversions.
Inheritance
Inherited Members
Namespace: FM.LiveSwitch
Assembly: FM.LiveSwitch.dll
Syntax
public class UnixTimestamp
Properties
UtcNow
Gets the current UTC time in Unix format.
Declaration
public static long UtcNow { get; }
Property Value
Type | Description |
---|---|
System.Int64 |
UtcNowMillis
Gets the current UTC time in Unix format with millisecond precision.
Declaration
public static long UtcNowMillis { get; }
Property Value
Type | Description |
---|---|
System.Int64 |
Methods
DateTimeToUnix(DateTime)
Converts a date to a Unix timestamp.
Declaration
public static long DateTimeToUnix(DateTime dateTime)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dateTime | The date to convert. |
Returns
Type | Description |
---|---|
System.Int64 | The equivalent Unix timestamp. |
DateTimeToUnixMillis(DateTime)
Converts a date to a Unix timestamp with millisecond precision.
Declaration
public static long DateTimeToUnixMillis(DateTime dateTime)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dateTime | The date to convert. |
Returns
Type | Description |
---|---|
System.Int64 | The equivalent Unix timestamp. |
TicksToUnix(Int64)
Converts ticks to a Unix timestamp.
Declaration
public static long TicksToUnix(long ticks)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | ticks | The ticks to convert. |
Returns
Type | Description |
---|---|
System.Int64 | The equivalent Unix timestamp. |
TicksToUnixMillis(Int64)
Converts ticks to a Unix timestamp with millisecond precision.
Declaration
public static long TicksToUnixMillis(long ticks)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | ticks | The ticks to convert. |
Returns
Type | Description |
---|---|
System.Int64 | The equivalent Unix timestamp. |
UnixMillisToDateTime(Int64)
Converts a Unix timestamp with millisecond precision to a date.
Declaration
public static DateTime UnixMillisToDateTime(long unix)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | unix | The Unix timestamp to convert. |
Returns
Type | Description |
---|---|
System.DateTime | The equivalent date. |
UnixMillisToTicks(Int64)
Converts a Unix timestamp with millisecond precision to ticks.
Declaration
public static long UnixMillisToTicks(long unix)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | unix | The Unix timestamp to convert. |
Returns
Type | Description |
---|---|
System.Int64 | The equivalent ticks. |
UnixToDateTime(Int64)
Converts a Unix timestamp to a date.
Declaration
public static DateTime UnixToDateTime(long unix)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | unix | The Unix timestamp to convert. |
Returns
Type | Description |
---|---|
System.DateTime | The equivalent date. |
UnixToTicks(Int64)
Converts a Unix timestamp to ticks.
Declaration
public static long UnixToTicks(long unix)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | unix | The Unix timestamp to convert. |
Returns
Type | Description |
---|---|
System.Int64 | The equivalent ticks. |