Frage

I assume I should be able to do it like so:

var date = Math.round((new Date).getTime() / 1000);
console.log(date);

However, that is logging:

301332453318

Which if I run through this convertor ( http://www.epochconverter.com/ ) it outputs the date as being:

GMT: Wed, 06 Nov 11518 03:13:03 GMT

Is it clearly not the year 11518 right now and my system time is correct so why is the Javascript time wrong - or am I doing it wrong?

Thanks, Thomas

War es hilfreich?

Lösung

Well this is weird. If I look at the time in the console it is correct, but if I highlight it and copy it for some reason chrome (or maybe OSX) is prepending the 30 onto it... WTF? Any ideas why?

enter image description here

In the image look at the logged time: 1332454189 (the correct time) but the 'highlighted' value (which is what I copied and pasted into the epoch convertor) for some reason has the 30 prepended onto it as evidenced by the "Search Google for '301332454189'"

Any ideas why?

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top