Getting Browser Timezone

http://stackoverflow.com/questions/2301905/how-does-javascript-date-object-determine-the-locale-of-the-users-browser
http://en.wikipedia.org/wiki/List_of_HTTP_header_fields

On the browser:

var d = new Date();
jQuery('#browserTimeOffset').val(Math.round(d.getTimezoneOffset() * 60));

On the server:

$browserTimeOffset = $_REQUEST['browserTimeOffset'];
$sql = "UPDATE member SET timeZoneOffsetInSeconds=unix_timestamp(utc_timestamp()) - unix_timestamp(now()) - $browserTimeOffset WHERE memberId=$memberId"
$offset = 555;  // Whatever the value of the timeZoneOffsetInSeconds column for this member
$sql = "SELECT cmnu.dModifiedDate + INTERVAL $offset second as dLastModifiedDate ..."

This method stores number of seconds offset between the browser and the database server. The timezone of my database server was America/Los_Angeles (where I lived, and does not need to be GMT).

If we do not want to use the above method, we can perhaps use relative date and times as mentioned in http://mayavps.com/articles/relative-dates-in-php-and-javascript/

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License