如何从 moment js 中提取国家名称以添加到对象中
How to extract the country name from moment js to add to an object
我有以下内容,我正在格式化时刻日期并将其存储到一个对象中,如下所示
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**
}
是否有格式选项可以让我将国家/地区名称分配给对象?
所以变量名将存储国家?
你可以这样尝试获取国家名称,
const countryName = moment.tz.guess(true);
'guess' 将 return 浏览器区域。
要获取浏览器区域以外的特定区域,
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);
我有以下内容,我正在格式化时刻日期并将其存储到一个对象中,如下所示
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**
}
是否有格式选项可以让我将国家/地区名称分配给对象? 所以变量名将存储国家?
你可以这样尝试获取国家名称,
const countryName = moment.tz.guess(true);
'guess' 将 return 浏览器区域。
要获取浏览器区域以外的特定区域,
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);