How do I get Greenwich Mean Time in PHP?

后端 未结 6 1227
情深已故
情深已故 2020-11-29 00:33

I have a server which is set to EST, and all records in the database are set to EST. I would like to know how to set it to GMT. I want to offer a time zone option to my user

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-29 01:26

    Here is a list of the time zones with different from GMT, hope this is helpful!

    echo '
    ';
    $zones_array = array();        
    $timestamp = time();         
    # to maintain the original timezone, store before
    $default_timezone = date_default_timezone_get();
    foreach (timezone_identifiers_list() as $key => $zone) {    
        date_default_timezone_set($zone);
        $zones_array[$key]['zone'] = $zone;
        $zones_array[$key]['diff_from_GMT'] = date('P', $timestamp);
    }
    # to maintain the original timezone, re-set after
    date_default_timezone_set($default_timezone);    
    print_r($zones_array);
    

    Thanks!

提交回复
热议问题