mirror of
https://github.com/smarty-php/smarty.git
synced 2025-11-02 21:31:48 +01:00
update date_format, allow optional 2nd paramater as default date if passed date is empty. update docs.
This commit is contained in:
@@ -6,13 +6,18 @@
|
||||
* Type: modifier
|
||||
* Name: date_format
|
||||
* Purpose: format datestamps via strftime
|
||||
* Input: string: input date string
|
||||
* format: strftime format for output
|
||||
* default_date: default date if $string is empty
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
require_once SMARTY_DIR . $this->plugins_dir . '/shared.make_timestamp.php';
|
||||
function smarty_modifier_date_format($string, $format="%b %e, %Y")
|
||||
function smarty_modifier_date_format($string, $format="%b %e, %Y", $default_date=null)
|
||||
{
|
||||
if($string != '') {
|
||||
return strftime($format, smarty_make_timestamp($string));
|
||||
} elseif (isset($default_date) && $default_date != '') {
|
||||
return strftime($format, smarty_make_timestamp($default_date));
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user