差分
ナビゲーションに移動
検索に移動
ページの作成:「<syntaxhighlight lang="csharp"> public static class DateTimeExtensions { private static readonly DateTime UNIX_EPOCH = new DateTime(1970, 1, 1, 0, 0, 0,...」
<syntaxhighlight lang="csharp">
public static class DateTimeExtensions
{
private static readonly DateTime UNIX_EPOCH = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
public static long ToUnixTime(this DateTime dateTime)
{
double nowTicks = (dateTime.ToUniversalTime() - UNIX_EPOCH).TotalSeconds;
return (long)nowTicks;
}
}
</syntaxhighlight>
public static class DateTimeExtensions
{
private static readonly DateTime UNIX_EPOCH = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
public static long ToUnixTime(this DateTime dateTime)
{
double nowTicks = (dateTime.ToUniversalTime() - UNIX_EPOCH).TotalSeconds;
return (long)nowTicks;
}
}
</syntaxhighlight>