gpt4 book ai didi

javascript - HTML 5 日期选择器在以 Angular 发送数据 ajax 时显示日期前一天

转载 作者:行者123 更新时间:2023-11-29 21:56:02 26 4
gpt4 key购买 nike

我正在使用 html5 datepicker,我使用 Angular mysql 通过 ajax 发送该值。我有表单日期,如果我选择 12/01,则发送错误,mydata 保存在 mysql 数据库中,如 11/01/。我不知道如何解决这个问题。我已在下面附上我的代码,提前致谢。

HTML:

<div class="col-sm-3" style="margin-bottom:10px;">
<input type="date" class="form-control" ng-model="date1" required>
</div>

JavaScript:

$scope.submitForm = function (){
//console.log();
var url = 'ajax/movies-master.php?action=add_movies';
var d1 = {'uname': this.theatername, 'moviename': this.moviename, 'date': this.date1, 'time': this.time1, 'price': this.price };
console.log(this.date1);
console.log('<br/>');
console.log(d1);
$http.post(url, d1
).success(function(data, status, headers, config) {
console.log(data);
console.log(data);
if (data.msg != '')
{
$scope.msgs = data.msg;
$scope.init();
$scope.cancelCreating();
}
else
{
$scope.errors = data.error;
$scope.init();
}
}).error(function(data, status) { // called asynchronously if an error occurs
// or server returns response with an error status.
$scope.errors.push(status);
});
}

PHP:

$data = json_decode(file_get_contents("php://input"));
$date = mysql_real_escape_string($data->date);

$query = mysql_query('INSERT INTO tablename (date) values ("' . $date . '")');

我正在像这样保存日期,但我的日期正在保存工作。

有谁知道吗,先谢谢了。

最佳答案

日期选择器总是为您提供当前日期前一天的日期..因此您需要在日期上添加+1...它肯定适合您

关于javascript - HTML 5 日期选择器在以 Angular 发送数据 ajax 时显示日期前一天,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33142677/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com