![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
DateTimeOffset.FromUnixTimeMilliseconds() Method in C#
The DateTimeOffset.FromUnixTimeMilliseconds() method in C# is used to convert a Unix time expressed as the number of milliseconds that have elapsed since 1970-01-01T00:00:00Z to a DateTimeOffset value.
Syntax
Following is the syntax −
public static DateTimeOffset FromUnixTimeMilliseconds (long val);
Above, Val are the milliseconds that have elapsed since 1970-01-01T00:00:00Z (January 1, 1970, at 12:00 AM UTC).
Example
Let us now see an example to implement the DateTimeOffset.FromUnixTimeMilliseconds() method −
using System; public class Demo { public static void Main() { DateTimeOffset offset = DateTimeOffset.FromUnixTimeMilliseconds(30000); Console.WriteLine("DateTimeOffset = {0} ",offset); Console.WriteLine("DateTimeOffset (other format) = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ",offset); } }
Output
This will produce the following output −
DateTimeOffset = 1/1/1970 12:00:30 AM +00:00 DateTimeOffset (other format) = 01 January 1970, 12:00:30
Example
Let us now see another example to implement the DateTimeOffset.FromUnixTimeMilliseconds() method −
using System; public class Demo { public static void Main() { DateTimeOffset offset = DateTimeOffset.FromUnixTimeMilliseconds(0); Console.WriteLine("DateTimeOffset = {0} ",offset); Console.WriteLine("DateTimeOffset (other format) = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ",offset); } }
Output
This will produce the following output −
DateTimeOffset = 1/1/1970 12:00:00 AM +00:00 DateTimeOffset (other format) = 01 January 1970, 12:00:00
Advertisements