Page 1 of 1

Reminder left and ago

Posted: 2015-05-10 14:03
by shahmmx
hi can someone help me,

this my code

function timetable_after_update($data, $memberInfo, &$args){


$then = date("Y-m-d H:i:s", strtotime("{$data['date']} {$data['time']}"));
$then = new DateTime($then);
$now = new DateTime();
$sinceThen = $then->diff($now);
$data['reminder'] = $sinceThen->d." days ".$sinceThen->h." hours ".$sinceThen->i." mins left";

return TRUE;
}

i want to change mins left to ago when the time expired, please someone guide me.

Re: Reminder left and ago

Posted: 2015-05-11 12:37
by a.gneady
Hmm .. how about:

Code: Select all

if($now > $then){
    $data['reminder'] = $sinceThen->d." days ".$sinceThen->h." hours ".$sinceThen->i." mins ago";
}else{
    $data['reminder'] = $sinceThen->d." days ".$sinceThen->h." hours ".$sinceThen->i." mins left";
}

Re: Reminder left and ago

Posted: 2015-05-12 15:33
by shahmmx
alhamdulillah, ty so much!

Re: Reminder left and ago

Posted: 2015-05-12 16:47
by shahmmx
its work with sql 5.5+ but not work in sql 5.1 or sql 5.2, im new in php + sql coding. what im missing?? please lend me some help here ;)

Re: Reminder left and ago

Posted: 2015-05-12 19:18
by shahmmx
sorry im nailed it, my last question how to do cron job to update field?