我在Angular中寫了一個應用程序,我正在使用Angular UI。我有一個日期選擇器,看起來像這樣:Angular UI日期選擇器出錯日期
<input type="text"
ng-required="true"
name="targetDate"
uib-datepicker-popup="MMMM yyyy"
min-mode="'month'"
datepicker-mode="'month'"
is-open="opened"
ng-click="openCalendar()"
close-on-date-selection="true"
show-button-bar="false"
min-date="today"
ng-model="targetDate" />
的問題是,當我選擇,例如,2016年7月,我在我的targetDate模型中的價值是「2016-06-30T21:00:00.000 Z「,這恰好是2016年7月之前的3小時。我認爲這與我的當地時間和UTC時間有關,因爲我住在當地時間爲UTC +2小時的地區,但我不知道爲什麼發生這種情況以及如何解決它。有任何想法嗎?
您需要使用MomentJs庫http://momentjs.com/docs/將UTC轉換爲本地時間。如果你已經知道的時候閱讀這個快速http://www.digitoffee.com/programming/get-local-time-utc-using-moment-js/94/ – Prasad
http://momentjs.com/docs/ for從開始使用 – Prasad
這個問題之前已經提到過:http://stackoverflow.com/questions/22623872/angular-ui-datepicker-adjusting-for-timezone – Akis