Right now my query looks like this (relevant part):
UPDATE last_seen=NOW()
But it inserts a time which is 2 hours earlier than mine. Is there any way to adjust it?
Thanks
Right now my query looks like this (relevant part):
UPDATE last_seen=NOW()
But it inserts a time which is 2 hours earlier than mine. Is there any way to adjust it?
Thanks
Set the timezone on your DB.. take a look this post. https://stackoverflow.com/a/3451971/1227435
This is another great resource:
I recommend you to try something like so:
Have an hidden input
to collect user's timezone
<input type="hidden" name="offset" class="offset">
$('.offset').val(new Date().getTimezoneOffset());
Then get it before the update and convert it to seconds like so
$offset = intval($_REQUEST['_offset']) * 60;
Finally add it to time()
:
$now = time() + $offset;
Doing the above, you have a variable with the client's time in his timezone. If you don't want that, and want a common time for everybody just set your time zone with this in your index.php
:
date_default_timezone_set('TIMEZONE IN HERE'); //Supported timezone list: http://www.php.net/manual/en/timezones.php
But it's better if you set it in your php.ini
(the timezone) or changing server's timezone (Debian/Ubuntu: dpkg-reconfigure tzdata
)
Sounds like MySQL is not on the same timezone as you.
You have some options:
http://dev.mysql.com/doc/refman//5.5/en/time-zone-support.html you need to set MySQL's notion` of timezone. Hope that helps...