我喜欢datetime-local字段在html中的显示方式,但是当我将它添加到我的数据库时,我相信它正在将时间转换为GMT。如何保持GMT不变,以便以正常格式显示时间?当我将字段切换到日期时间时,它没有相同的外观,它没有格式化,因此您可以从日历中选择,单击向上/向下等。
HTML:
<input type="datetime-local" ng-model="mealtime" placeholder="mealtime"></br>
angularJs:
$scope.addMeal = function() {
$http({
method: 'POST',
contentType: 'application/json',
url: "/api/addMeal/",
dataType: 'json',
data: JSON.stringify({us: $scope.user, token:$scope.token, mealtime:$scope.mealtime, calories:$scope.calories, memo:$scope.memo}),
}).then(function(response) {
$scope.meals = response['data']
console
});
};
app.py
mealtime = request.json["mealtime"]
mealday = mealtime[:-14]
mealhours = mealtime[-13:-5]
mymeal = Meal(time = mealhours, day = mealday).save()
另外,我发现如果我将{{datetime}}添加到我的代码中,则角度会立即将我的日期时间转换为0z时间,即“2015-01-01T13:01:00.000Z”