How to find out the number of days between two dates
How to find out the number of days between two dates
i am trying to get number of days between two given dates, but while trying this way its not giving the number of days.
$pur_dt = date_create('2015-08-03'); $todate = date_create(date('Y-m-d')); $diff = date_diff($todate,$pur_dt); print_r($diff); echo $diff->format('%R%a days'); if($diff>15) //checking condition if $pur_dt - $todate > 15 { echo 'Hello you are not eligible'; } else { echo 'eligible'; }
its not working, not giving the number of days between given two dates.
Answer by BKO for How to find out the number of days between two dates
Try this,
$pur_dt = date_create('2015-08-03'); $todate = date_create(date('Y-m-d')); $datediff = $pur_dt - $todate; $diff = $datediff/(60*60*24); if($diff>15) //checking condition if $pur_dt - $todate > 15 { echo 'Hello you are not eligible'; } else { echo 'eligible'; }
Answer by Amit Rajput for How to find out the number of days between two dates
Try this. It is very simple.
Answer by javedrathod for How to find out the number of days between two dates
Try This :
$pur_dt = Date('2015-08-03'); $todate = Date(date('Y-m-d')); $pur_dt = strtotime($pur_dt); $todate = strtotime($todate); $seconds_diff = $todate - $pur_dt; $$diff = floor($seconds_diff/(60*60*24)); if($diff>15) //checking condition if $pur_dt - $todate > 15 { echo 'Hello you are not eligible'; } else { echo 'eligible'; }
Answer by budirec for How to find out the number of days between two dates
It's better using DateTime class, you can see comment(9) at PHP manual as it answer your question
Answer by Amit Visodiya for How to find out the number of days between two dates
Try this
$pur_dt = date_create('2015-08-03'); $todate = date_create(date('Y-m-d')); $diff = date_diff($todate,$pur_dt); print_r($diff); echo $diff->format('%R%a days'); if($diff->days>15) //checking condition if $pur_dt - $todate > 15 { echo 'Hello you are not eligible'; } else { echo 'eligible'; }
Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72
0 comments:
Post a Comment