this question has answer here:
im looking less complicated way following:
$joindate = "2014-05-26" $date = date('ymd'); //todays date $memberfor = $joindate - $date //this need total number of days
is there function can me this?
you should using datetime object these operations
$joindate = "2014-05-26"; $joindate_obj = new datetime($joindate); $now = new datetime(); $interval = $joindate_obj->diff($now); $diff = $interval->d ; echo $diff; //12
the object $interval
have
dateinterval object ( [y] => 0 [m] => 11 [d] => 12 [h] => 12 [i] => 49 [s] => 4 [weekday] => 0 [weekday_behavior] => 0 [first_last_day_of] => 0 [invert] => 0 [days] => 347 [special_type] => 0 [special_amount] => 0 [have_weekday_relative] => 0 [have_special_relative] => 0
) may use example $interval->days
difference in days.
Comments
Post a Comment