D
D
Dima Pautov2020-01-20 19:06:04
JavaScript
Dima Pautov, 2020-01-20 19:06:04

Why are dates different in node.js and browser?

I use nuxt.js with ssr. I have authorization, after successful authorization cookies are set.
The date for expires comes in this format 2020-01-20 19:09:46 +03:00
For cookies on the server and client 1, the format of the options is:

{
  expires: new Date(expireAt),
}

But the server (node.js) parses the date into this format,
2020-01-20T16:05:40.000Z
and the client into this:
Mon Jan 20 2020 19:09:46 GMT+0300 (Москва, стандартное время)

From which the cookie is set normally on the client, but immediately rots on the server side. Help me figure out how to correctly convert the date to a single format

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Shohruh Shaimardonov, 2020-01-20
@joeberetta

These are 2 identical dates in different formats. You can see for yourself

console.log(new Date ('Mon Jan 20 2020 19:09:46 GMT+0300').getTime() == new Date('2020-01-20T16:05:40.000Z').getTime());

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question