Angular.js:输入日期显示日期-1天 [英] Angular.js: Input date shows date -1 day
本文介绍了Angular.js:输入日期显示日期-1天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有< input type = date>
的表单。
I have a form with <input type="date">
.
当我在此输入中绑定数据时,它显示的是日期-1天。
When I bind data in this input, it shows me the date -1 day.
HTML:
<div class="input-field col s12">
<label>Fecha Nacimiento </label>
<input type="date" class="form-control" id="fnac" name="fnac" ng-model="unapersona.fnac">
</div>
控制器:
$scope.cargarpersona = function(id) {
$http.get("modelos/personas_json.php?id="+id)
.success(function(data) {
$scope.unapersona = eval(data);
//... Other data
$scope.unapersona.fnac = new Date($scope.unapersona[0]["fnac"]);
//... Other data
})
.error(function(data) {
console.log('Error: ' + data);
});
}
推荐答案
已解决!
我只是将 ng-model-options = {timezone'UTC'} 放入输入日期
Solved!! Just I put the ng-model-options = "{timezone 'UTC'} into the input date
<input type="date" class="form-control" id="fnac" name="fnac" ng-model="unapersona.fnac" ng-model-options="{timezone:'UTC'}">
https://docs.angularjs.org/api/ng/directive/ngModelOptions
感谢您的回答和时间!
这篇关于Angular.js:输入日期显示日期-1天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文