i have variable $a='2015-05-12 10:00:00'.
now need compare above variable current date , time , find time difference between two.
requirement enable div tag when time difference 3 hours or less.
p.s: $a variable. how can convert date , time , compare current date , time.?
currently tried code is
$todaysdate=date('y-m-d'); $a=$date.' '.$starttime; $todaysdate=date_create(date("y-m-d ", strtotime($todaysdate))); $final_date=date_create(date("y-m-d ", strtotime($a))); $diff_date = date_diff($todaysdate, $final_date); $total_diff=$diff_date->format('%r%a');
which give date difference.but need 3 hours difference in time.any appreciated.
i hope helps you..
$a='2015-05-12 10:00:00'; $todaysdate = strtotime("now"); $final_date= strtotime($a); $diff=$todaysdate-$final_date; echo ($diff/3600)." hours ";
Comments
Post a Comment