我使用类型 date 来获取日期,但我选择的日期和保存在数据库中的日期不同。保存的日期将始终是我选择的日期的前一天。例如,在我的输入中,日期是 8 月 8 日,但在数据库中它保存为 8 月 7 日。我该如何解决这个问题,以及如何在没有 T16:00:00.000Z 的情况下显示日期。
奶制品.html
<div>
<label> Date: </label>
<input type="date" ng-model="diary.date">
</div>
数据.html
<table style="width:90%" align="center" class="t3" ng-controller="RetrieveDiaryController">
<tr>
<th style="width:40%">Date</th>
<th style="width:30%">Type</th>
<th style="width:30%">Level</th>
</tr>
<tr ng-repeat="d in diaries | orderBy:'date':true">
<td>{{d.date}}</td>
<td>{{d.taken}}</td>
<td>{{d.level}}</td>
</tr>
</table>
健康.js
.
controller('TrackingController', ['$scope', 'Diary', '$state', function($scope, Diary, $state) {
$scope.diaries = [];
$scope.submitForm = function() {
Diary
.upsert({
date: $scope.diary.date,
taken: $scope.diary.taken,
level: $scope.diary.level
})
.$promise
.then(function() {
$state.go('data');
});
};
}])
.controller('RetrieveDiaryController', ['$scope', 'Diary', function ($scope, Diary) {
$scope.diaries = Diary.find();
}])