[英]Date and Time Zone offset
我必須使用時間偏移值來更改時間。 我通過
// serwer time is XYZ Time Zone date time
$date_today_tz = date("Y-m-d H:i"); // actual date time from XYZ time zone
$time_diff_UTC = date('P'); // diff to UTC
$_time = explode(":",$time_diff_UTC);
$time_diff_UTC_strt = $_time[0]." hours ".$_time[1]." minutes";
and
gmdate('Y-m-d H:i:s', strtotime($time_diff_UTC_strt, strtotime($date_today_tz)));
我有一個來自XYZ時區的時間和一個距UTC的時間偏移(到此時間)(例如-07:00)
$time_diff_UTC = date('P');
但是(對於我的代碼的另一部分),我必須具有此偏移量的值,但帶有相反的符號f.ex。
-07:00 -> +07:00
+01:00 -> -01:00
ect.
作為最簡單的方法嗎?
你有沒有嘗試過
str_replace(array('-','+','#'), array('#','-','+'), $time_diff_UTC)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.