我想标题会说明一切。我的php脚本中是否有一种方法可以将php的时区更改为服务器的时区,以便strtotime()和SQL的UNIX_TIMESTAMP将返回相同的结果?
答案 0 :(得分:0)
您只需将php.ini中的时区配置更改为;
即可date.timezone = UTC
答案 1 :(得分:0)
您可以使用date_default_timezone_set函数设置所需的时区。或者,您可以在php.ini文件中设置date.timezone =“您想要的值”,如果您可以编辑它。
答案 2 :(得分:-1)
您可以使用PHP函数 -
date_default_timezone_set(string $ timezone_identifier);
您可以从下面获取$ timezone_identifier的值 -
'Kwajalein' => -12.00
'Pacific/Midway' => -11.00,
'Pacific/Honolulu' => -10.00,
'America/Anchorage' => -9.00,
'America/Los_Angeles' => -8.00,
'America/Denver' => -7.00,
'America/Tegucigalpa' => -6.00,
'America/New_York' => -5.00,
'America/Caracas' => -4.30,
'America/Halifax' => -4.00,
'America/St_Johns' => -3.30,
'America/Argentina/Buenos_Aires' => -3.00,
'America/Sao_Paulo' => -3.00,
'Atlantic/South_Georgia' => -2.00,
'Atlantic/Azores' => -1.00,
'Europe/Dublin' => 0,
'Europe/Belgrade' => 1.00,
'Europe/Minsk' => 2.00,
'Asia/Kuwait' => 3.00,
'Asia/Tehran' => 3.30,
'Asia/Muscat' => 4.00,
'Asia/Yekaterinburg' => 5.00,
'Asia/Kolkata' => 5.30,
'Asia/Katmandu' => 5.45,
'Asia/Dhaka' => 6.00,
'Asia/Rangoon' => 6.30,
'Asia/Krasnoyarsk' => 7.00,
'Asia/Brunei' => 8.00,
'Asia/Seoul' => 9.00,
'Australia/Darwin' => 9.30,
'Australia/Canberra' => 10.00,
'Asia/Magadan' => 11.00,
'Pacific/Fiji' => 12.00,
'Pacific/Tongatapu' => 13.00