PHP date timestamp timezone not converted properly -
so have code:
$timestamp = 1414708099; echo $timestamp; $date = date_make_date($timestamp, 'utc', 'datestamp'); date_timezone_set($date, timezone_open('america/new_york')); $timestamp = $date->format('u'); echo '<br>'; echo $timestamp;
which supposed convert timezone of initial timestamp utc new york.
but ends printing
1414708099<br>1414708099
hence timezone didnt change...
what did wrong?
btw uses drupal 6 date_api.module: http://drupalcontrib.org/api/drupal/contributions!date!date_api.module/function/date_make_date/6
as per comments
a timestamp always utc. can't apply time zone timestamp - consider timezone 0. whatever do, stays 0. asked date formatted u - manual states this:
u: seconds since unix epoch (january 1 1970 00:00:00 gmt).
you can't seconds unix epoch new york. number same location in world. now, had formatted date using, say, $date->format('y-m-d h:i:s')
correctly formatted time timezone offset new york.
long story short - there no problem whatsoever here. works intended.
php date datetime timezone datetime-format
No comments:
Post a Comment