Smartyで数日前/数日後を計算
基準日からの経過した(明日、昨日、週、秒、分、時間)日時の計算方法
Smarty
{* 現在 2024/12/14 *}
{$smarty.now|date_format:'%Y/%m/%d'}
{* PHP 8.1 Function strftime() is deprecated 対応 *}
{$smarty.now|date_format:'Y/m/d'}
{* 明日 2024/12/15 *}
{assign var="tomorrow" value=$smarty.now+24*60*60}
{$tomorrow|date_format:'%Y/%m/%d'}
{$tomorrow|date_format:'Y/m/d'}
{* 昨日 2024/12/13 *}
{assign var="yesterday" value=$smarty.now-24*60*60}
{$yesterday|date_format:'%Y/%m/%d'}
{$yesterday|date_format:'Y/m/d'}
{* 1週間後 2024/12/21 *}
{assign var="week" value=$smarty.now+24*60*60*7}
{$week|date_format:'%Y/%m/%d'}
{$week|date_format:'Y/m/d'}
{* 30秒後 2024-12-14 05:44:58 *}
{assign var="second" value=$smarty.now+30}
{$second|date_format:'%Y/%m/%d %H:%M:%S'}
{$second|date_format:'Y/m/d H:i:s'}
{* 30分後 2024-12-14 06:14:28 *}
{assign var="minute" value=$smarty.now+60*30}
{$minute|date_format:'%Y/%m/%d %H:%M:%S'}
{$minute|date_format:'Y/m/d H:i:s'}
{* 24時間後 2024-12-15 05:44:28 *}
{assign var="hour" value=$smarty.now+24*60*60}
{$hour|date_format:'%Y/%m/%d %H:%M:%S'}
{$hour|date_format:'Y/m/d H:i:s'}
{* 任意の日付 $date = 2024-12-14 *}
{* 明日 2024/12/15 *}
{assign var="tomorrow" value=$date|strtotime+24*60*60}
{$tomorrow|date_format:'%Y/%m/%d'}
{* 昨日 2024/12/13 *}
{assign var="yesterday" value=$date|strtotime-24*60*60}
{$yesterday|date_format:'%Y/%m/%d'}