'How to extract the country name from moment js to add to an object

I have the following where i am formatting the moment date and storing it into an object as follows

async date(){
 var today=Moment() **// today gets stored as Wed Mar 16 2022 12:05:07 GMT+0200 (Standard Time)'**
var date= today.format("dddd,D MMM YYYY"); /**/ date gets stored as Wednesday,16 Mar 2022**
var name= **how do i add what the name of the country is thats been returned after the GMT+0200 so it would be Standard Time**
}

is there a format option that i can assign the Country name to an object? so the variable name will store the country?



Solution 1:[1]

You can try like this to get the country name,

const countryName = moment.tz.guess(true);

'guess' will return the browser zone.

To get particular zone other than browser zone,

const countryName = moment.tz.zone('America/New_York').countries(); // This will return an array from which we can pass the value to locale()
moment.locale(countryName);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 RGA