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

        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