I know this is probably a question for ServerFault but I am having difficulty logging in.
I have an Ubuntu instance in the cloud running Nginx + PHP5-fpm.
I have set the timezone in php.ini to Asia/Singapore
and verified it is set in phpinfo()
.
I have set the OS timezone using dpkg-reconfigure tzdata
as well.
For some time, I've been having trouble with wrong dates set in my application. I initially thought this might be something I did in my PHP setup, so in my bootstrap script, I included:
date_default_timezone_set('Asia/Singapore');
Tried installing timezonedb via PECL as suggested in this post: Setting default timezone does not work despite timezone being valid
A user set date set on a webform still gets translated to "yesterday" when processed. I have tried both date()
& gmdate()
in PHP with the same results.
Edit
A little more information in case.
User selects a date with
jQuery DatePicker
On form submission, I send the timestamp back to the server for PHP to process & store. I divide the timestamp by 1000 in PHP before storing.
<?php $timestamp = (int) $_POST['birthday'] / 1000 // this is received from a form.
Upon echoing the date & timestamp,
<?php echo date('dS F Y', (int) $timestamp); // when rendering to HTML... // computes to 13th April 1981 //JS new Date(data.timestamp * 1e3).toString() // the exact same timestamp from earlier but received from server. // computes to Tue Apr 14 1981 23:30:00 GMT+0730 (SGT)
Any ideas?