[英]How to get date object timezone text in french?
When I use new Date() I get o/p as Mon Nov 30 2020 16:41:46 GMT-0500 (Eastern Standard Time)
.当我使用 new Date() 时,我得到 o/p 为
Mon Nov 30 2020 16:41:46 GMT-0500 (Eastern Standard Time)
。 Can I get Eastern Standard Time
in french?我可以用法语获得
Eastern Standard Time
吗? I tried with the following, but didn't work.我尝试了以下方法,但没有奏效。 Is there any method to return french text?
有什么方法可以返回法语文本吗?
var d = new Date(); console.log(d); console.log(d.toLocaleString("fr-FR"));
I need to detect the visitor timezone and display it as Eastern etc.. timezone.我需要检测访客时区并将其显示为东部等时区。 Since, my app is in french, is there a way to get the visitor timezone and translate it into french.
因为,我的应用程序是法语的,有没有办法获取访问者时区并将其翻译成法语。 I know I can do it by using translate service.
我知道我可以通过使用翻译服务来做到这一点。 I am just curious if there is a method that translates the timezone automatically to desired language.
我只是好奇是否有一种方法可以将时区自动翻译成所需的语言。 Everything is translated with toLocaleString, just the Eastern Standard Time.
一切都用 toLocaleString 翻译,只是东部标准时间。 I can pass options as
const options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
我可以将选项传递为
const options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
, is there a option for EST. ,是否有 EST 选项。
This works for me这对我有用
var d= new Date(); var options = { weekday: 'long', year: 'numeric', month:'long', day: 'numeric' }; //options.timeZone = "UTC"; options.timeZoneName = "long"; console.log(d.toLocaleDateString("fr-FR", options));
This prints "lundi 30 novembre 2020 à heure normale d'Europe centrale"这打印“lundi 30 novembre 2020 à heure normale d'Europe centrale”
Modify the options to suit your needs:)修改选项以满足您的需要:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.