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# | Random.Next() Method
- C# | Method Parameters
- C# | Math.Abs() Method | Set - 2
- C# | Method Overriding
- Main Method in C#
- Decimal.Add() Method in C#
- Method Hiding in C#
- C# | IsNullOrEmpty() Method
- Stack.Contains() Method in C#
- Stack.Pop() Method in C#
- C# | Uri.ToString() Method
- C# | Math.Exp() Method
- C# | Math.Abs() Method | Set - 1
- Queue.Contains() Method in C#
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.