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?
Asked
Active
Viewed 195 times
0
-
This is already answered here: https://stackoverflow.com/questions/3830244/get-current-date-time-in-seconds – antirealm Nov 27 '18 at 05:25
1 Answers
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
-
1
-
Ok...how i get the total number of seconds since epoch from date in UTC time? – Ferchs C Nov 27 '18 at 04:43