|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
schildi Smarty Regular
Joined: 11 Mar 2005 Posts: 81
|
Posted: Fri Mar 18, 2005 7:12 pm Post subject: smarty_function_date_format |
|
|
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 |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Mar 18, 2005 7:45 pm Post subject: |
|
|
You can do this too:
{assign var="formatted_date" value=$time|date_format} |
|
Back to top |
|
schildi Smarty Regular
Joined: 11 Mar 2005 Posts: 81
|
Posted: Fri Mar 18, 2005 8:52 pm Post subject: |
|
|
mohrt wrote: | You can do this too:
{assign var="formatted_date" value=$time|date_format} |
well.. good to know
thanks |
|
Back to top |
|
|
|
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
|