我正面臨着一個奇怪的問題。角度/ javascript html輸入類型'時間'顯示錯誤提交時間
以我形式我使用2個輸入,類型爲「時間」:
<div style="float:left;width:50%;">
<div style="background:#efefef;!important;line-height:30px;font-size:14px;text-transform: uppercase;text-align:center;border:none">
Start time
<input type="time" name="start_time" formatted-time ng-model="editFields.disable_freelance_start_time" style="width:100%;border:1px solid #ccc;border-right:none;margin-bottom:10px;padding:5px;" />
</div>
</div>
<div style="float:left;width:50%">
<div style="background:#efefef;!important;line-height:30px;font-size:14px;text-transform: uppercase;text-align:center;border:none;border-left:2px solid #ccc">
End time
<input type="time" name="end_time" formatted-time ng-model="editFields.disable_freelance_end_time" style="width:100%;border:1px solid #ccc;border-left:none;margin-bottom:10px;padding:5px;" />
</div>
</div>
和在我的控制器設置我的模型:
$scope.editFields.disable_freelance_start_time = new Date();
$scope.editFields.disable_freelance_end_time = new Date();
並在視圖它示出了在合適的時間輸入 - 當前時間(見屏幕截圖)
但是當我「提交表單」並檢查對象時,它顯示錯誤的值 - 時間是2個小時了..(我住在阿姆斯特丹, ?或許真的與夏令)
它顯示了這一點:
[start_time] => 2016-05-17T01:21:56.382Z
[end_time] => 2016-05-17T01:21:56.382Z
所以它顯示1:21,但現在是03:21 - 這究竟是爲什麼以及如何解決這個問題?
其正常,獲得TimeZoneOffset,這是在幾分鐘內,你可以手動計算。 – YOU
請注意時區爲Z或GMT。阿姆斯特丹是GMT + 0200,「2016-05-17T01:21:56.382Z」與「2016-05-17T03:21:56.382 + 0200」的時間相同。 – RobG
我明白,但我把這個發送到我的PHP後端,我把它作爲一個字符串。我應該在PHP中處理這個嗎? – rZaaaa