im using a JQuery calender and trying to save the date into the database, but on the response nothing shows.
If i alert the it on the Javascript side its there but not on the PHP server side. I can echo the other data but not date.
function create(id,fname,lname,Date) {
alert(Date);
console.log(Date);
//giving var's key names for the array
var array1={id:id,
firstname:fname,
lastname:lname,
date:Date};
alert(array1);
$.ajax({
type: 'POST',
url: '<?= B_SITE_URL; ?>/clinic/booking/UpdateCalender',
timeout: 100000,
data: array1,
cache: false,
success: function (response) {
alert("Sent Data"+response);
}
});
}
and this is the date format.
var startDateObj = new Date(parseInt(startYear), parseInt(startMonth) - 1,
parseInt(startDay), startHour, startMin, 0, 0);
and this is my php function
function actionUpdateCalender(){
echo "<pre>";
if (isset ($_POST)){
echo $id =$_POST['firstname'];
echo $day =$_POST['date'];
}
echo "</pre>";
self::setView(false);
}
i changed the Var to userdate and then used .toLocaleString . it now echo's out the date, which i have to insert into the DB.
function create(id,fname,lname,userdate) {
alert(userdate);
console.log(userdate);
//giving var's key names for the array
var array1={id:id,
firstname:fname,
lastname:lname,
userdate:userdate.toLocaleString()};
$.ajax({
type: 'POST',
url: '<?= B_SITE_URL; ?>/clinic/booking/UpdateCalender',
timeout: 100000,
data: array1,
cache: false,
success: function (response) {
alert("Sent Data"+response);
}
});
}