我在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