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
  • 21,590
  • 73
  • 223
  • 402

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,378
  • 5
  • 32
  • 66