javascript - Convert set date to user's local time automatically -


i creating application have pretty big set of dates , times, , need display these in user's local time , date. set dates , times in bst; example 08-24-2014 16:00 bst = 08-24-2014 11:00 est. now, before coming here spent 3-4 hours looking answer if anything, got more confused. is there way, convert set of bst dates , times user's local settings automatically without them setting time zone etc?

p.s.: have 2 ideas in mind don't know if work nor how execute them.

1) , change bst date , time , convert unit of measurement; , change user's local date , time , covert same unit of measurement above, calculate difference in new measurement, , convert user's local time.

2) use geolocation find user's date , time/ time zone and; convert bst whatever geolocation spits out.

you can users machine timezone in javascript:

var currentdate = new date(); var currenttimezoneoffsetinhours = currentdate.gettimezoneoffset() / 60; 

see documentation here: https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/date/gettimezoneoffset

having offset can add values


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -