Home › Forums › Front-end Issues › Show content based on timepicker value › Reply To: Show content based on timepicker value
Thanks for looking at this
<?php get_field(‘morning_start_time’); ?>
Was throwing up an error, because of php within php maybe? Went with
<?php date_default_timezone_set('Europe/London'); // timezone $weekday = date(l); // today $now = new DateTime(); $morning = $now >= new DateTime(get_field('morning_start_time','option')) && $now <= new DateTime(get_field('morning_end_time','option')); $afternoon = $now >= new DateTime(get_field('evening_start_time','option')) && $now <= new DateTime(get_field('evening_end_time','option')); if($weekday == "Saturday" && ($morning || $afternoon)) : ?> <h2>We're streaming</h2> <?php else : ?> <h2>No streaming</h2> <?php endif; ?>
It doesn’t throw up an error but its also not working. Would that be because of the php date/time functions? My return format is H:i currently
Or is there an easier way to make this work? I just can’t work this out
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We’re hard at work on ACF 6.1, and Beta 1 is now available 🚀— Advanced Custom Fields (@wp_acf) March 16, 2023
This release includes custom post type and taxonomy registration, an improved experience when selecting field types, PHP 8.1 and 8.2 compatibility, and more!
Let’s take a look 🧵https://t.co/Y0WcAT11l4
© 2023 Advanced Custom Fields.