Reminder left and ago

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
User avatar
shahmmx
Posts: 4
Joined: 2015-05-10 13:46

Reminder left and ago

Post by shahmmx » 2015-05-10 14:03

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.

User avatar
a.gneady
Site Admin
Posts: 1354
Joined: 2012-09-27 14:46
Contact:

Re: Reminder left and ago

Post by a.gneady » 2015-05-11 12:37

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";
}
:idea: AppGini plugins to add more power to your apps:

User avatar
shahmmx
Posts: 4
Joined: 2015-05-10 13:46

Re: Reminder left and ago

Post by shahmmx » 2015-05-12 15:33

alhamdulillah, ty so much!

User avatar
shahmmx
Posts: 4
Joined: 2015-05-10 13:46

Re: Reminder left and ago

Post by shahmmx » 2015-05-12 16:47

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 ;)

User avatar
shahmmx
Posts: 4
Joined: 2015-05-10 13:46

Re: Reminder left and ago

Post by shahmmx » 2015-05-12 19:18

sorry im nailed it, my last question how to do cron job to update field?

Post Reply