DateTimeOffset.FromUnixTimeSeconds(Int64) Method is used to convert a Unix time expressed as the number of seconds that have elapsed since 1970-01-01T00:00:00Z to a DateTimeOffset value.
Syntax: public static DateTimeOffset FromUnixTimeSeconds (long seconds);
Here, it takes a Unix time, expressed as the number of seconds 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: This method returns s date and time value that represents the same moment in time as the Unix time.
Exception: This method will give ArgumentOutOfRangeException if seconds is less than -62,135,596,800 or seconds is greater than 253,402,300,799.
Below programs illustrate the use of DateTimeOffset.FromUnixTimeSeconds(Int64) Method:
DateTimeOffset is 01/01/1970 02:46:40 +00:00
Example 2: For ArgumentOutOfRangeException
Exception Thrown: System.ArgumentOutOfRangeException
- Difference between Method Overriding and Method Hiding in C#
- C# | CopyTo() Method
- C# | Random.Next() Method
- C# | Trim() Method
- C# | Uri.IsHexDigit() Method
- C# | Uri.FromHex() Method
- C# | Join() Method | Set - 1
- C# | PadLeft() Method
- C# | Uri.IsBaseOf(Uri) Method
- C# | IndexOfAny() Method
- C# | SortedDictionary.Add() Method
- C# | Math.Pow() Method
- C# | Copy() Method
- C# | Join Method | Set - 2
- C# | Method Overriding
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.