问题
I want to change timezone in Date object itself, because device(web browser?) itself doesn't support timezone.
How I change it?
For example:
var date = new Date();
// Value is "Mon Jun 19 2017 10:00:08 GMT+0000 (GMT)"
date.setTimezoneOffset("+09.00"); // For example
// Value is "Mon Jun 19 2017 01:00:08 GMT+0900 (GMT)"
I don't want to use like this:
var date = new Date();
// Value is "Mon Jun 19 2017 10:00:08 GMT+0000 (GMT)"
date.setTimezoneOffset("+09.00"); // For example
// Value is "Mon Jun 19 2017 01:00:08 GMT+0000 (GMT)"
Thanks.
回答1:
I want to change timezone in Date object itself, because device(web browser?) itself doesn't support timezone.
How I change it?
You can't. The ECMAScript Date object doesn't have a timezone, it's UTC internally. The offset is supplied by the host system.
If you want to support different time zones, write your own functions or use a library that supports them.
来源:https://stackoverflow.com/questions/44623363/javascript-set-timezone-in-date-object-itself-like-settimeoffset