شرح كيفية عمل و ضبط التاريخ و الساعة فى سمارتي 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