Javascript code:
<!DOCTYPE html>
<html>
<title>Web Page Design</title>
<head>
<script>
function sayHello() {
//var date1 = new Date("11/28/2018");
//var date2 = new Date("12/1/2018");
var date1 = new Date("2018-11-28");
var date2 = new Date("2018-12-01");
var timeDiff = Math.abs(date2.getTime() - date1.getTime());
var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));
alert(diffDays);
}
sayHello();
</script>
</head>
<body>
</body>
</html>
PHP code:
$date1=date_create("2013-03-15");
$date2=date_create("2013-12-12");
$diff=date_diff($date1,$date2);
echo $diff->format("%R%a days");
OR
<!DOCTYPE html>
<html>
<title>Web Page Design</title>
<head>
<script>
function sayHello() {
//var date1 = new Date("11/28/2018");
//var date2 = new Date("12/1/2018");
var date1 = new Date("2018-11-28");
var date2 = new Date("2018-12-01");
var timeDiff = Math.abs(date2.getTime() - date1.getTime());
var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));
alert(diffDays);
}
sayHello();
</script>
</head>
<body>
</body>
</html>
PHP code:
$date1=date_create("2013-03-15");
$date2=date_create("2013-12-12");
$diff=date_diff($date1,$date2);
echo $diff->format("%R%a days");
OR
$startDate = strtotime('2018-12-01');
$toDay = strtotime(date('Y-m-d'));
$time = abs($toDay - $loginDate);
$days = floor($time / 86400);