0

My question is very simple... Consider the following Angular App simply create a new date and print the number of UTC milliseconds of that date in the console. My question is why is it zero?

Ferchs C
  • 25
  • 6
  • This is already answered here: https://stackoverflow.com/questions/3830244/get-current-date-time-in-seconds – antirealm Nov 27 '18 at 05:25

1 Answers1

0

Because getUTCSeconds is the seconds portion of the time. In your case its 0.

Docs : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCSeconds

Examples:

new Date('July 20, 1969, 20:18:04 UTC'); // 4 
new Date('July 20, 1969, 20:18:00 UTC'); // 0 

It is not the total number of seconds since epoch (which is what you might be thinking)

basarat
  • 261,912
  • 58
  • 460
  • 511