0

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.

Park
  • 85
  • 8
  • Did you check this ? https://stackoverflow.com/questions/439630/how-do-you-create-a-javascript-date-object-with-a-set-timezone-without-using-a-s – Mohamed Abbas Jun 19 '17 at 06:15

1 Answers1

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.

RobG
  • 142,382
  • 31
  • 172
  • 209