2012-08-06 67 views
0

我想獲取時間的時區,與當地時間相同,但在GMT其他地區。獲取時間戳的時區

還有就是我想將工作:

ceil((strtotime($scores[$i]['date'].' '.$scores[$i]['time'])-strtotime(date('d F Y H:i',strtotime("-2 hours"))))/3600) 

,但它給了我-26,-22,等..

鏈接到測試站點,測試數據:[LINK刪除]

謝謝你的幫助。

+0

這將會是有益的,如果你表現出什麼樣的輸入值。一些隨機時間戳是無用的。像嵌套strtotime()調用的事情是**不**是一個好兆頭。 timestamp-> string-> timestamp是cpu週期的無用浪費。 – 2012-08-06 01:37:26

+0

@MarcB這不是隨機的,這些日期是在一個數據庫中。服務器的GMT是+2(我已經更新FTP上的文件,請重新加載鏈接) – mark0ba 2012-08-06 01:42:35

+0

它們對我們來說是隨機的 - 顯然這些數字是壞時區,但由於我們無法看到這些時間值來自哪裏,我們無法幫助您解決實際問題。你要求我們在爛房子上塗一層新的油漆,而忽略了房子腐爛的事實。 – 2012-08-06 01:43:24

回答

0

我發現這個邏輯推理,但我不知道爲什麼是這樣,但現在,它工作正常...

代碼:

如果(小區((strtotime($ scores [$ i] ['date']。''。$ scores [$ i] ['time']) - strtotime(date('d FYH:i',strtotime(「 - 2 hours」 ))))/ 3600)< -12){0} {0} {'time']) -strtotime(date('d FYH:i',strtotime(「 - 2 hours」))))/ 3600))+ 24;

}否則{

回波小區((的strtotime($分數[$ i]於[ '日期']「 '$分數[$ i]中。[ '時間']) - 的strtotime(日期(' d FYH:i',strtotime(「 - 2 hours」))))/ 3600); }

:)