0

I am currently using this code:

 var stringSecsNow = DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds.ToString();

But is there some other way. I seem to recall in another language that there was an easier way to do this?

Alan2
  • 23,493
  • 79
  • 256
  • 450

1 Answers1

0

Almost same but looks easier.

DateTime PreviousDateTime = new DateTime(1970, 1, 1);
var stringSecsNow = (DateTime.UtcNow - PreviousDateTime).TotalSeconds.ToString();
Mohit S
  • 13,723
  • 6
  • 34
  • 69