skip to Main Content

I can’t find a solution to this:

I only want to compare two date and timestamps with eachother like this ->

 {if $CONFIG.ENDDATE lte $smarty.now|date_format:"%Y%m%d %H:%M"}

$CONFIG.ENDDATE and $smarty.now are Strings (Like this: string(14) "20231218 16:02"). Unfortunately, it doesn’t work the way I imagined it would. Does anyone have any ideas or tips?

I tried it with this Post Compare two dates in smarty

but this does not work with timestamps. If I only use this:

{if $CONFIG.ENDDATE lte $smarty.now|date_format:"%Y%m%d"}

and only compare dates, then everything works as it should.

2

Answers


  1. Chosen as BEST ANSWER

    I've solved the problem like this:

    {if $CONFIG.ENDDATE|strtotime lte $smarty.now}
    

  2. Instead of string, you must change $CONFIG.ENDDATE to timestamp.

    you can try this, it will work:

    {if $CONFIG.ENDDATE lte $smarty.now}
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search