I send UNIX timestamp from javascript vat stamp = +new Date/1000
to PHP.
Then I do
//Here $d = '2015/04/03 00:00:00'
$d = new DateTime("@{$stamp}");
$d->setTimezone( new DateTimeZone( 'Pacific/Auckland' ) );
//Here $d = '2015/04/03 00:00:00' + 7:15 hrs ( 7:15 hrs is time diff between my browser & Auckland)
I want to change the timezone but keep the date to same. So, after I setTimezone
to Pacific/Auckland
, the date should still be '2015/04/03 00:00:00'
.
Here's one way to do it.
$_date = new \DateTime($date->format('Y-m-d H:i:s'), new \DateTimeZone('<time zone>'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With