note 48325 deleted from function.time by tularis

From: Date: Sun, 19 Dec 2004 16:31:20 +0000
Subject: note 48325 deleted from function.time by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-82050@lists.php.net to get a copy of this message
Note Submitter: raul at buenhospedaje dot com ---- I think this note could help to people they want to avoid mysql use, and just to generate the websites dynamically each 5 minutes or something similar, so you just need to know the difference of the index with the current date time. The best solution is implemented using this simple but usefull functions. $month1 = date('n',$timestamp1); $month2 = date('n',$timestamp2); $diff = $month2-$month1; echo(($diff > 0 ? $diff-1 : $diff+1)); ---- First date: 920264400 Second date: 974240831 $differecne = $first - $second; echo $difference; Returns: Difference: 53976431 $diffday = $difference/86400; echo "$diffday (days)"; Returns this: Difference: 624.73377314815 (days) How can I further format this figure to display like: Difference: 624 days, X hours, X minutes, and X seconds $string_difference = date("H:m:s",mktime(0,0,$diff,0,0,0)) // I think that'll work. ---- $filemod = filemtime( 'headlines.txt' ); $now = time(); $seconds = $now - $filemod; /**************************** Make Minutes ****************************/ $minutes = floor( $seconds / ( int )60 ); /**************************** Get Left Over Seconds ****************************/ $left = $minutes * ( int )60; $a_seconds = $seconds - $left; /**************************** Output Message ****************************/ echo( 'File last modifed ' . $minutes . ' minute(s) and ' . $a_seconds . ' second(s) ago.' ); I hope it helps people. Raul Mate Galan Ceo Buenhospedaje www.buenhospedaje.com ---- Reason: useless example

« previous php.notes (#82050) next »