How to get user timezone using javascript

How to get user timezone using javascript

How to get user timezone using javascript:

Time zone setup is very useful, while you are working in a project for different countries. Last day worked such a project and had faced big issue on how to get user timezone using JavaScript. It’s very simple and easy to find out user time zone and manipulate your data according to time zone. Here goes script –

function get_time_zone_offset( ) {
                    var current_date = new Date();
                    return -current_date.getTimezoneOffset() / 60;
                }

var user_time_zone = get_time_zone_offset();

 

This script return user time zone offset.

Example: If you are from Bangladesh then this function return “6” for Asia timezone.

Enjoy!

Was this information useful? What other tips would you like to read about in the future? Share your comments, feedback and experiences with us by commenting below!

Share It

Related Posts