workshopper / learnyounode

Learn You The Node.js For Much Win! An intro to Node.js via a set of self-guided workshops.
Other
7.24k stars 1.84k forks source link

JSON API server offset missing in Unix time? #645

Closed kvedantmahajan closed 4 years ago

kvedantmahajan commented 5 years ago

Don't you think guys, offset is an issue while returning d.getTime();

I think it should be

function getUnixTime(d) {
    const offset = d.getTimezoneOffset() * 60 * 1000;
    const withOffset = d.getTime();
    return withOffset - offset;
}

I just referred here - https://stackoverflow.com/questions/9229213/convert-iso-date-to-milliseconds-in-javascript

Let me know your thoughts for timeZone difference!

ccarruitero commented 4 years ago

Hi @kushalmahajan,

I don't think offset will be a problem in this case since you are running and using the server in local.

shanmukhateja commented 4 years ago

This issue can be closed as it does not seem to be a real bug.