note 110750 added to function.time

From: Date: Sat, 01 Dec 2012 00:13:21 +0000
Subject: note 110750 added to function.time
Groups: php.notes 
Request: Send a blank email to php-notes+get-192240@lists.php.net to get a copy of this message
This function returns a string in the format of 'y, d, h, s' or 'year, day, hour, second'(if $full is set to true) for a input value in seconds as $time. An 's' is added to the units with values greater than 1 when returning a string in the 'year, day, hour, second' format. function timetostring($time, $full=false){ $time= ($time>=31536000?floor($time/31536000).($full?" year".(floor($time/31536000)>1?"s":""):"y").", ":""). ($time%31536000>=86400?floor($time%31536000/86400).($full?" day".(floor($time%31536000/86400)>1?"s":""):"d").", ":""). ($time%31536000%86400>=3600?floor($time%31536000%86400/3600).($full?" hour".(floor($time%31536000%86400/3600)>1?"s":""):"h").", ":""). ($time%31536000%86400%3600>=60?floor($time%31536000%86400%3600/60).($full?" minute".(floor($time%31536000%86400%3600/60)>1?"s":""):"m").", ":""). ($time%31536000%86400%3600%60>0?($time%31536000%86400%3600%60).($full?" second".(floor($time%31536000%86400%3600%60)>1?"s":""):"s").", ":"") ; return substr($time,0,strlen($time)-2); } ---- Server IP: 69.147.83.199 Probable Submitter: 72.52.91.2 (proxied: 66.42.160.59) ---- Manual Page -- http://www.php.net/manual/en/function.time.php Edit -- https://master.php.net/note/edit/110750 Del: integrated -- https://master.php.net/note/delete/110750/integrated Del: useless -- https://master.php.net/note/delete/110750/useless Del: bad code -- https://master.php.net/note/delete/110750/bad+code Del: spam -- https://master.php.net/note/delete/110750/spam Del: non-english -- https://master.php.net/note/delete/110750/non-english Del: in docs -- https://master.php.net/note/delete/110750/in+docs Del: other reasons-- https://master.php.net/note/delete/110750 Reject -- https://master.php.net/note/reject/110750 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#192240) next »