when I want to get current time, I get time 2 hours less. I tried get time from terminal and it was wrong too, but I have set everiting well. Any idea?
Asked
Active
Viewed 79 times
0
-
2Is it because it gives you the time in UTC and you're in a UTC+2 timezone? – VLAZ Sep 22 '18 at 17:18
-
My timezone is Europe/Prague – Radek336 Sep 22 '18 at 17:29
-
OK, so it tracks - this is currently at UTC+2: it's CET, so UTC+1 normally but +1 again for summer time. [UNIX timestamp seems to be timezone independant](https://stackoverflow.com/questions/23062515/do-unix-timestamps-change-across-timezones], hence it would be giving you UTC. When reading it, you'd need to apply the timezone if you wish to convert to local time. Which makes sense because otherwise 10 o'clock in UTC+1 and 10 o'clock in UTC +2 would be different timestamps. – VLAZ Sep 22 '18 at 17:34
-
Okay, so what I can do when nodejs saves current date to mongodb like this 2018-09-22T12:23:11.473Z? – Radek336 Sep 22 '18 at 17:44
-
I don't know - what do you want to do with this? That's format is also valid - it's an ISO 8601 date string. It is again in UTC time - the **Z** in the end stands for Zulo time (honestly, never figured out why it's called that) which is the +0 time zone. It will be equivalent to a UNIX timestamp if both are converted to the same date representation. – VLAZ Sep 22 '18 at 17:51
-
Oh, everything is OK, I was just confused, thanks – Radek336 Sep 22 '18 at 18:04