How to get the current time in seconds with C#

1 Answer

0 votes
using System;
  
class CurrentTimeInSeconds_CSharp
{
    static void Main() {
        long milliseconds = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
        
        long seconds = milliseconds / 1000;
        
        Console.WriteLine(seconds);
    }
}
  
  
  
/*
run:
  
63858784772
 
*/

 



answered Aug 9, 2024 by avibootz
...