Problems, need help? Have a tip or advice? Post it here.
15 posts Page 2 of 2
To add one more solution - please see viewtopic.php?p=14737#p14737

There are several useful date related threads listed at one place here - viewtopic.php?p=15150#p15150
Yes, I found that thread but was waiting to see if there were native couch tags that could handle this before doing php. Thanks kk, although seems Tim's solution is working and calculating days correctly. :) Will see if it says 16 days tomorrow. :)
Will see if it says 16 days tomorrow. :)

Hey, c'mon! Have a little faith! :lol:

I'll admit that last bit is a little ugly, compensating for the unexpected fractional inaccuracy. All I can say is that I've seen that sort of thing before when a computation returns a marginal fraction instead of the integer I was expecting.

If anyone can explain why it's happening, or has a cleaner way of dealing with it, I'd be interested to hear about it.
Thanks, Tim. Happened to come by this thread.

Backwards conversion from the 'U' time format:
Code: Select all
  <cms:set today = "<cms:date format='Y-m-d H:i:s' />" />
  <cms:show today /><br>
  <cms:set today = "<cms:date today format='U' />" />
  <cms:show today /><br>

  <cms:set today = "<cms:php>echo date('Y-m-d H:i:s',<cms:show today />);</cms:php>" />

  <cms:show today />
 

Calculating tomorrow as another example
Code: Select all
 <cms:set today_d = "<cms:date format='Y-m-d' />" /><br>
  <cms:show today_d />
  <cms:set today_d = "<cms:date today_d format='U' />" /><br>
  <cms:show today_d />
<cms:set one_day = "<cms:mul '3600' '24' />" /><br>
  <cms:show one_day />
  <cms:set tomorrow_d = "<cms:add today_d one_day />" /><br>
  <cms:show tomorrow_d />
<cms:set tomorrow = "<cms:php>echo date('Y-m-d H:i:s',<cms:show tomorrow_d />);</cms:php>" /><br>
  <cms:show tomorrow />
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Also:
Code: Select all
Plus one hour
<cms:set one_hour = "<cms:php>echo date('Y-m-d H:i:s',<cms:add "<cms:date format='U' />" '3600' />);</cms:php>" />
<cms:show one_hour />

Plus 30days
<cms:set plus_30days = "<cms:php>echo date('Y-m-d H:i:s',<cms:add "<cms:date format='U' />" '2592000' />);</cms:php>" />
<cms:show plus_30days />
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
15 posts Page 2 of 2