AngularUI的DatePicker - JavaScript的 - 日期休息一天让当SQL日期格式 [英] AngularUI DatePicker - JavaScript - Date one day off when getting SQL Date format
问题描述
我加载一个SQL格式的日期插入变量2014年2月28日,但是当我创建一个
I load in a SQL format date into a variable "2014-02-28" , but when I create a
new Date("2014-02-28");
在输入框中显示的日期是:
the Date displayed in the input box is:
2014-02-27
在AngularUI日期选择器,日期始终是一天下来即使该值是在模型是正确的。是否有某种方式来解决这个问题?
In the AngularUI datepicker, the date is always one day off even if the value is correct in the model. Is there some way to remedy this?
下面是一个Plunkr链接,演示了此问题: http://plnkr.co /编辑/ evBwPW0KO7cEWGp6vqtk?p = preVIEW
Here is a Plunkr link which demonstrates the problem: http://plnkr.co/edit/evBwPW0KO7cEWGp6vqtk?p=preview
我想该模型只是在YYYY-MM-dd格式的日期,并为日期是正确的。
I would like the model to be just the date in yyyy-MM-dd format, and for the date to be correct.
推荐答案
更改日期格式
yyyy/MM/dd
解决了这一问题。
fixed the problem
var date = new Date("2014-02-28"); // date loaded in SQL format
date.replace(new RegExp("-", 'g'),"/"); // now datepicker will show correct date
这篇关于AngularUI的DatePicker - JavaScript的 - 日期休息一天让当SQL日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!