Smarty Date and Time zone
, Timezone


Designers can then use date_format to have complete control of the formatting of the date. If the date passed to date_format is empty and a second parameter is passed, that will be used as the date to format.



{$smarty.now}

{$smarty.now}The current timestamp can be accessed with {$smarty.now}. The value reflects the number of seconds passed since the so-called Epoch on January 1, 1970, and can be passed directly to the date_format modifier for display. Note that time() is called on each invocation; eg a script that takes three seconds to execute with a call to $smarty.now at start and end will show the three second difference.

{* use the date_format modifier to show current date and time *}
{$smarty.now|date_format:'%Y-%m-%d %H:%M:%S'}

*************************************************
:
*************************************************

Jan 1, 2022
01/01/22
02:33 pm
Dec 31, 2021
Monday, December 1, 2021
14:33:00
###############################
:
###############################

1- PHP :


:
<?php

$config['date'] = '%I:%M %p';
$config['time'] = '%H:%M:%S';
$smarty->assign('config', $config);
$smarty->assign('yesterday', strtotime('-1 day'));

?>
2- TPL :


:
{$smarty.now|date_format}
{$smarty.now|date_format:"%D"}
{$smarty.now|date_format:$config.date}
{$yesterday|date_format}
{$yesterday|date_format:"%A, %B %e, %Y"}
{$yesterday|date_format:$config.time}
###############################
:
###############################



Timezone Smarty

" z% " TPL Php

:
ini_set('date.timezone', 'Egypt');
:
https://www.smarty.net/docsv2/en/lan...ate.format.tpl
https://www.smarty.net/docsv2/en/lan...les.smarty.now