Re: [SMARTY] A pluggin to convert second in H:M:S
| From: | messju mohr | Date: | Tue, 25 Feb 2003 16:44:53 +0000 |
| Subject: | Re: [SMARTY] A pluggin to convert second in H:M:S | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-8189@lists.php.net to get a copy of this message | ||
Hello,
On Tue, Feb 25, 2003 at 08:35:44AM +0100, Juzan Jean-Michel wrote:
> <?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);
>
> echo sprintf("%02d", $hours).".".sprintf("%02d",
> $minute).".".sprintf("%02d", $secconde);
you can do
printf("%02d.%02d.%02d", $hours, $minute, $secconde);
if you like and save a few function calls.
have fun
messju
> }
> ?>