Angular.js:输入日期显示日期-1天

2024-01-02

我有一个表格<input type="date">.

当我在此输入中绑定数据时,它会显示日期 -1 天。

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);
    });
}

屏幕截图 https://i.stack.imgur.com/zvCXd.png


解决了!! 只是我把ng-model-options = "{时区 'UTC'}进入输入日期

<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 https://docs.angularjs.org/api/ng/directive/ngModelOptions

感谢您的回答和时间!

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Angular.js:输入日期显示日期-1天 的相关文章

随机推荐