Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

smarty_function_date_format

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks
View previous topic :: View next topic  
Author Message
schildi
Smarty Regular


Joined: 11 Mar 2005
Posts: 81

PostPosted: Fri Mar 18, 2005 7:12 pm    Post subject: smarty_function_date_format Reply with quote

maybe somebody needs it too (when using assign as parameter result is saved in the according variable)


Code:
function smarty_function_date_format($params, &$smarty)
{
    require_once $smarty->_get_plugin_filepath('shared','make_timestamp');
   $result = "";
   $format = "%b %e, %Y";
   if (substr(PHP_OS,0,3) == 'WIN') {
           $_win_from = array ('%e',  '%T',       '%D');
           $_win_to   = array ('%#d', '%H:%M:%S', '%m/%d/%y');
           $format = str_replace($_win_from, $_win_to, $format);
    }
   if(isset($params['format']))
   {
      $format = $params['format'];
   }
   $result = strftime($format, smarty_make_timestamp($params['timestamp']));
   if(isset($params['assign']))
   {
      $smarty->assign($params['assign'], $result);
   }
   else
   {
      return $result;
   }
}
Back to top
View user's profile Send private message Send e-mail
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Fri Mar 18, 2005 7:45 pm    Post subject: Reply with quote

You can do this too:

{assign var="formatted_date" value=$time|date_format}
Back to top
View user's profile Send private message Visit poster's website
schildi
Smarty Regular


Joined: 11 Mar 2005
Posts: 81

PostPosted: Fri Mar 18, 2005 8:52 pm    Post subject: Reply with quote

mohrt wrote:
You can do this too:

{assign var="formatted_date" value=$time|date_format}


well.. good to know Smile
thanks
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP