Smarty: unix timestamp to date


/ Published in: PHP
Save to your folder(s)

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

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.