Pip Posted June 16, 2021 Share Posted June 16, 2021 Hi everyone! Prolly this is the most noobest question. But how do you work on date times in Processwire templates? I've been working on one that will check if it's the current day and not over a certain time. PHP wise it's easy. But on a Processwire template, it spits out as an error. $wholedatetime = DateTime("now", new DateTimeZone('Asia/Singapore') ); $currentdate = $wholedatetime->format('Y/m/d'); $currenttime = $wholedatetime->format('H'); echo $page->batchdate; if ($currentdate != $page->batchdate) { if ($currenttime < 23) { $formflag = 2; } } Help! Link to comment Share on other sites More sharing options...
pideluxe Posted June 16, 2021 Share Posted June 16, 2021 Have a look at the API docs for the $datetime variable (https://processwire.com/api/ref/wire-date-time/). Just insert the date form PW page as argument and convert it to the format you like. 1 Link to comment Share on other sites More sharing options...
Pip Posted June 16, 2021 Author Share Posted June 16, 2021 15 minutes ago, pideluxe said: Have a look at the API docs for the $datetime variable (https://processwire.com/api/ref/wire-date-time/). Just insert the date form PW page as argument and convert it to the format you like. I misunderstood the documentation! Got it working now. Thanks a ton! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now