Re: [SMARTY] Re: A pluggin to convert second in H:M:S

From: Date: Wed, 26 Feb 2003 00:01:28 +0000
Subject: Re: [SMARTY] Re: A pluggin to convert second in H:M:S
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-8202@lists.php.net to get a copy of this message
This is a pluggin suggestion If you want to add some others properties... Thank's messju for the efficient suggestion ;) I plan to create another function to give the year old with birthday date in parameters (useful for Curriculum Vitae online or other stuff), but I have some problem with date before 1970 function smarty_function_getyearold ($params, &$smarty) { extract($params); // $bithday need to send in timestamp $datenow = time (); $yearold = date("Y",$datenow) - date("Y",$birthday); if( (mktime(0,0,0, date("n", $datenow), date("j", $datenow), date("Y", $datenow)) - mktime(0,0,0, date("n", $birthday), date("j", $birthday), date("Y", $birthday))) < 0 ) { $yearold--; } echo $yearold; } <?php /* * Smarty plugin * ------------------------------------------------------------- * Type: function * Name: gethms * Purpose: Convert second in H.M.S * Usage: {gethms secondes=$TimeInSecond} * ------------------------------------------------------------- */ function smarty_function_gethms($params, &$smarty) { extract($params); $hours = floor($secondes / 3600); $minute = floor(($secondes - ($hours * 3600)) / 60); $secconde = $secondes - ($hours * 3600) - ($minute * 60); printf("%02d.%02d.%02d", $hours, $minute, $secconde); } ?> Le mar 25/02/2003 à 17:57, Tom Sommer a écrit : > On 25 Feb 2003 08:35:44 +0100, Juzan Jean-Michel wrote: > > > function smarty_function_gethms($params, &$smarty) > > { > > > extract($params); > > > $hours = floor($secondes / 3600); > > $minute = floor(($secondes - ($hours * 3600)) / 60); > > $secconde = $secondes - ($hours * 3600) - ($minute * 60); > > > > echo sprintf("%02d", $hours).".".sprintf("%02d", > > $minute).".".sprintf("%02d", $secconde); > > } > > ?> > > Why not also days, months, years ? > > -- > Tom Sommer, denmark > www.tsn.dk - www.dreamcoder.dk > > -- > Smarty General Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- Jean-Michel Juzan jmjuzan@ecreasol.ch Direction Informations & Technologies eCreaSol - NetWork Creative Solutions SARL - http://www.ecreasol.ch/ PGP public keys server : http://www.keyserver.net

Attachment: [application/pgp-signature] signature.asc
« previous php.smarty.general (#8202) next »