This members-only tutorial provides the steps to register a custom condition using which elements in Oxygen can be set to be output before, after or at a specified date or date and time.
The date and time is to be entered in this format: Y-m-d H:i:s.
Ex.: 2021-03-25 16:30:00
With the above (per screenshot) set for a Section, it will be output only after the 25th of March 2021 4:30 pm in the timezone set in WordPress settings.
If time is omitted, it will be taken as midnight (12am).
Even though Oxygen has built-in Date and Time conditions, as of Oxygen 3.7 they do not use the Date/Time improvements added in WordPress 5.3.
This condition uses the recommended function, current_datetime() and the recommended approach, DateTimeImmutable class.
Also, the built-in Date condition shows the placeholder as MM/DD/YYYY when it should be Y-m-d. Date entered in MM/DD/YYYY format in the built-in Date condition will not work.
Install and activate Code Snippets plugin.
Go to Snippets > Add New.
Title: [Condition] Date and time
This is a premium members-only content.
To view the rest of the content, please sign up for membership ($47/month or $399 one-time).
Already a member? Log in below or here.
Enter your email address to subscribe to this blog and receive notifications of new tutorials by email.
Join 565 other subscribers
Please log in again.
The login page will open in a new tab. After logging in you can close it and return to this page.