phpdateprestashopsmartyprestashop-1.6

How to add "N" days to $smarty.now?


I have a parameter in my page called 'priceValidUntil', for this parameter I have the line:

<meta itemprop="priceValidUntil" content="{$smarty.now|date_format:'%Y-%m-%d %H:%M:%S'}">

I want to add to the $smarty.now value 15 days, so I've added this:

 <meta itemprop="priceValidUntil" content="{$smarty.now|date_format:'%Y-%m-%d %H:%M:%S' + 15 }">

The output is this:

 <meta itemprop="priceValidUntil" content="2024-04-27 23:04:05">

I want:

<meta itemprop="priceValidUntil" content="2019-05-12 23:04:05">

How can I add days instead of years?


Solution

  • Method 1

    According to this link, it seems you might be able to do so, maybe by adding:

     {$smarty.now+24*60*60*15|date_format:'%Y-%m-%d %H:%M:%S'}
    

    to your content attribute.

    Method 2

    You might simply try this:

    {"+15 days"|strtotime|date_format:'%Y-%m-%d %H:%M:%S'}
    

    Then, your code might look like:

    <meta itemprop="priceValidUntil" content="{$smarty.now+1296000|date_format:'%Y-%m-%d %H:%M:%S'}">