【发布时间】:2018-01-23 19:44:36
【问题描述】:
我正在尝试从我的 HTML 5 表单转换日期:
<form ng-submit="Add()">
<input type="text" ng-model="Data.title" />
<input type="date" ng-model="Data.date"/>
</form>
我的 Azure T-Sql 数据库 - 日期 - 需要以下内容:
2018-01-23T18:18:43.768Z
但它来自表单:
Wed Jan 17 2018 00:00:00 GMT+0100 (W. Europe Standard Time)
如何将 html5 输入日期转换为正确格式,以便提交表单
$scope.Add = function () {
var request = 'additem';
var Date = $scope.Data.date;
$http({
method: 'POST',
url: uri + request,
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
data:
$.param({
title: $scope.Data.title,
date: $scope.Data.date
})
}).success(function (data, status, headers, config) {
})
};
我应该如何转换日期以便数据库除了表单,如果我将日期部分更改为字符串,它工作得很好。
【问题讨论】:
标签: javascript angularjs html azure date