Skip to content
This repository has been archived by the owner on Jul 21, 2024. It is now read-only.

Commit

Permalink
Added the possibility to convert a DateTime to UnixTime (#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
lpeyr committed Jul 2, 2022
1 parent 5a03b56 commit ca0da14
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions LeoCorpLibrary/Env.cs
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,12 @@ public static DateTime UnixTimeToDateTime(int unixTime)
return dtDateTime; // Return the result
}

public static int DateTimeToUnixTime(DateTime dateTime)
{
DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); // Create a date
return (int)dateTime.Subtract(dtDateTime).TotalSeconds; // Return the result
}

/// <summary>
/// Gets if a specified process name is currently running.
/// </summary>
Expand Down

0 comments on commit ca0da14

Please sign in to comment.