Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
77
rated 0 times [  83] [ 6]  / answers: 1 / hits: 45119  / 6 Years ago, wed, april 4, 2018, 12:00:00

I want to get the Current Date object in UTC. I tried using new Date(), Date.now() etc. But they return the local time. How do I get the UTC date object?


I want the Date object, not string representation.


More From » node.js

 Answers
22

Just use new Date(new Date().toUTCString())



After converting to UTC, we have to again convert it into Date object if we need a Date Object.


[#54770] Monday, April 2, 2018, 6 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
gideons

Total Points: 197
Total Questions: 106
Total Answers: 108

Location: Moldova
Member since Sat, Jan 29, 2022
2 Years ago
gideons questions
Tue, Nov 9, 21, 00:00, 3 Years ago
Sat, Jan 2, 21, 00:00, 3 Years ago
Wed, Oct 28, 20, 00:00, 4 Years ago
Thu, May 21, 20, 00:00, 4 Years ago
;