Posted By

FrankBr on 01/18/08


Tagged

date Smarty unix timestamp


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

FrankBr
drwitt


Smarty: unix timestamp to date


 / Published in: PHP
 

A simple but usefull smarty plugin to convert a unix timestamp to any date format.

Usage: {$var|convertunix:"d-m-Y"}

  1. <?php
  2. /**
  3.  * Smarty plugin
  4.  * @package Smarty
  5.  * @subpackage plugins
  6.  */
  7.  
  8.  
  9. /**
  10.  * Smarty convert to unix
  11.  *
  12.  * Type: modifier
  13.  * Name: convertunix
  14.  * Purpose: convert unix timestamp to date
  15.  * @author Frank Broersen
  16.  * @param string
  17.  * @return string
  18.  */
  19. function smarty_modifier_convertunix($sString,$sFormat)
  20. {
  21. return gmdate($sFormat, $sString);
  22. }
  23. ?>

Report this snippet  

You need to login to post a comment.