datetime - How do I get midnight of current day in a specified timezone in PHP? -


i have server in new york, , "client" in california expects server figure out midnight of current day in california, not same new york's 3 hours out of day.

i have been able calculate midnight current day seen new york, need able calculate midnight of current day california (or other arbitrary timezone)

i have access timezone's offset utc.

$tzoffset = "-700"; // timezone offset utc (in case, pdt) 

the (semi-working) method i'm using right is

strtotime("00:00:00 " . $tzoffset); 

on jun 25 @ 10:00 pm pdt, method returning jun 26 @ 12:00 pdt midnight, when should returning jun 25 12:00 pdt.

// create time string $date_time = new datetime('midnight', new datetimezone('america/los_angeles')); // string representation of time in america/los_angeles echo $date_time->format('y-m-d h:i:s') . php_eol; $date_time->settimezone(new datetimezone('america/new_york')); // string representation of same time in america/new_york echo $date_time->format('y-m-d h:i:s') . php_eol; 

http://php.net/manual/en/datetime.formats.php


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -