Advertisement
DigitalMag

From/To Unix time

Jun 7th, 2020
1,053
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.55 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication1
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.            
  13.             var stamp = TimeSpan.FromTicks(new DateTime(1970, 1, 1).Ticks).TotalMilliseconds;
  14.             var now = TimeSpan.FromTicks(DateTime.Now.Ticks).TotalMilliseconds - stamp;
  15.  
  16.             var Time = new DateTime(1970, 1, 1).AddMilliseconds(now);
  17.  
  18.             Console.Write(Time);
  19.             Console.Read();
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement