PHP adjust time zone for date

后端 未结 2 1605
野趣味
野趣味 2021-01-14 06:09

The following output on my website is -1 hr, and I just wanted a quick fix to adjust it accordingly, but I\'m not sure of the correct syntax...



        
相关标签:
2条回答
  • 2021-01-14 06:42

    set default time zone

    $timezone = 'America/Los_Angeles';
    $stored_time = '2011-01-30 18:23:49';
    
    date_default_timezone_set($timezone);
    $timestamp = strtotime($stored_time);
    $local_time = $timestamp + date('Z');
    $local_date = date('Y-m-d H:i:s', $local_time);
    
    echo $local_date;
    
    0 讨论(0)
  • 2021-01-14 06:53

    Use the date_default_timezone_set function of PHP to set the your timezone as default it is taking the timezone of server.

    Here is the list of timezones.

    0 讨论(0)
提交回复
热议问题