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 use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.