Reputation: 7204
When I call my function:
formatDate(new Date("2020-06-08T10:37:05.915+0000")
function formatDate(tstamp) {
return new Intl.DateTimeFormat("en-GB", {
year: "numeric",month: "2-digit",day: "2-digit",
hour: "2-digit", minute: "2-digit",second: "2-digit"
}).format(tstamp);
}
My output is: 08/06/2020, 12:37:05 why I got (12:37:05) instead (10:37:05) my timezone is GMT+2.
Upvotes: 0
Views: 116
Reputation: 4873
It is because the input is GMT+0000 and you are GMT+0200 which is 2 hours ahead Greenwich Mean Time. The format
method formats a date without changing its time value.
Upvotes: 1