我使用html5 datepicker,我通過使用角度mysql的ajax發送該值。我有表格日期,在發送錯誤,如果我選擇12/01,mydata保存在mysql數據庫像11/01 /。我不知道如何解決這個問題。我已經附上了我的代碼,提前致謝。HTML 5 datepicker顯示日期前一天,當以角度發送數據ajax時
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 . '")');
我保存日期這樣的,但我的日期被降耗工作。
任何人都可以知道這一點,在此先感謝。
你是什麼日期列的類型?日期時間,時間戳,日期等? –
我保留日期.... – Vijaykarthik
您的專欄名稱是日期,對不對?嘗試使用'當你調用它。就像這個''... INSERT INTO tablename('date')values ...''因爲日期是保留字。 –