Reputation: 3092
I am currently in the UK.
I am obtaining a date from my api which is the following string value = "2021-06-15T21:00:00Z"
.
But when I want to convert this to a Date object using:
let formattedStartDateTime: Date = new Date("2021-06-15T21:00:00Z");
I get the following result = Tue Jun 15 2021 22:00:00 GMT+0100 (British Summer Time).
Why am I getting British Summer Time? I'm running this today so I would expect it to be GMT+0000
Upvotes: 0
Views: 136
Reputation: 660
The date you are storing and outputting are the same, you are just outputting your local date instead of the UTC date, this should do what you want.
let formattedStartDateTime: Date = new Date("2021-06-15T21:00:00Z");
console.log(formattedStartDateTime.toUTCString());
Upvotes: 2