xoligy Posted June 2, 2008 Share Posted June 2, 2008 Ok at the moment im working on a script and im trying to make it so when a pm is sent it says message was sent "x" seconds, minutes, hrs ago. Now i have the code (i believe i just cannot for the live of me get it to work because im stupid lol! Ok here is the code for messages <?=vDate($messages[$i]->date)?> // this would output the time 22:30 or May 30, 2008 additional code function vDate($time){ $timenow=time(); $timenow=date ("M d, Y",$timenow); $time1=date ("M d, Y",$time); if ($timenow==$time1){ $time1=date ("H:i",$time); } return $time1; } Code im trying to replace it with but canna figure out how o.0 function getDateDiff($age){ $timet = 3600*24; $days=floor($age/$timet); $hours=floor($age/3600); $minutes=floor($age/60); $seconds=$age; if ($days>0) $age ="$days days ago"; else if ($hours>0) $age ="$hours hr".(($hours>1)?"s":"")." ago"; else if ($minutes>0) $age ="$minutes min".(($minutes>1)?"s":"")." ago"; else $age ="$seconds sec".(($seconds>1)?"s":"")." ago"; return $age; }//EOF $pastdate = 1209358800;//April 28 2008 $datedif = time()-$pastdate;//subtract the past date from the current time //now run the function echo getDateDiff($datedif); Link to comment https://forums.phpfreaks.com/topic/108457-change-date-to-x-minutes-ago-messages/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.