我的页面中有一个名为'priceValidUntil'的参数,对于这个参数,我有一行:
<meta itemprop="priceValidUntil" content="{$smarty.now|date_format:'%Y-%m-%d %H:%M:%S'}">
我想在15天内添加$smarty.now
值,所以我添加了这个:
<meta itemprop="priceValidUntil" content="{$smarty.now|date_format:'%Y-%m-%d %H:%M:%S' + 15 }">
输出是这样的:
<meta itemprop="priceValidUntil" content="2024-04-27 23:04:05">
我想要:
<meta itemprop="priceValidUntil" content="2019-05-12 23:04:05">
我怎样才能添加天而不是几年?
根据this link的说法,似乎你可以这样做,也许可以添加:
{$smarty.now+24*60*60*15|date_format:'%Y-%m-%d %H:%M:%S'}
你的content
属性。
$smarty.now
变量的秒数。<meta itemprop="priceValidUntil" content="{$smarty.now+15*24*60*60|date_format:'%Y-%m-%d %H:%M:%S'}">
你可能只是试试这个:
{"+15 days"|strtotime|date_format:'%Y-%m-%d %H:%M:%S'}
然后,您的代码可能如下所示:
<meta itemprop="priceValidUntil" content="{$smarty.now+1296000|date_format:'%Y-%m-%d %H:%M:%S'}">