I need to get client side timezone using JavaScript. I am using below code.
new Date().toString().split('(')[1].slice(0, -1)
But it returns timezone daylightname, and I need id.
For example, client side timezone as set as (UTC-05:00) Eastern Time (US & Canada)
and I need to get output as Eastern Standard Time
. But I am getting Eastern Daylight Time
as output.
Can I do this without any additional plugin requirements?
Try the following
var objdatetime = new Date();
var timezone = objdatetime.toTimeString();
var tzstr = timezone.split("(");
var timezoneid = tzstr[1].toString().replace(")","");
alert(timezoneid);
这个怎么样?
new Date().toString().split('(')[1].slice(0, -1).replace('Daylight', 'Standard')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.