My code for gettin date in jquery is given below :
var pathname = window.location.pathname; // Returns path only
var url = window.location.href; // Returns full URL
var splits =url.split('?');
if(splits[1])
{
var splits2 = splits[1].split('=');
var newDate = splits2[1];
}
else
{
var date = new Date(),
yr = date.getFullYear(),
month = date.getMonth() < 10 ? '0' + date.getMonth() : date.getMonth(),
day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate(),
newDate = yr + '-' + month + '-' + day;
}
After this i am sending this to php code :
$.ajax({
type:'post',
url:'<?php echo BASE_URL; ?>dashboard/get_weedays',
async:false,
data:{date : newDate},
success:function(response)
{
var obj = JSON.parse(response);
design_for_week(obj);
}
})
In php i am getting this date and converting it into strtotime
but its returning me the different values .In php i am doing this
$date = $this->input->post("date");
$dt = strtotime($date);
echo $dt;exit;
for date 2018-11-06 timestamp in php is : 1541442600
but when i pass the date from the ajax and after getting it on php it return me timestam like : 1541442600
both are different can anyone please suggest me fo this ? how can i solve this 1541615400