I want to calculate the difference between two dates in php. I am trying with the following code, here I am getting the above error. How to solve this one?
<?php
date_default_timezone_set('Asia/Calcutta');
$date1 = date('Y-m-d H:i:s'); //2012-03-10 17:58:52
$date2 = 2013-07-03 10:25:50;
$difference = (strtotime($date2) – strtotime($date1)) / (60*60*24);
echo "date is".$difference ; ?>
I need the differece with both date and time. Where is the problem giving error?
If I try like this,
$difference = abs(strtotime($date2) – strtotime($date1));
Parse error: syntax error, unexpected T_VARIABLE
Thanks.
Here is your solution, I have change the code for you.
It is working for me try yourself and check it.