Support

Account

Forum Replies Created

  • The times I’m trying to show are acf fields on an options page. Would that make a difference as to it working or not here?

  • 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

  • So its setup so that content:
    <h2>We’re streaming</h2>

    Will show between the times –
    $morning = $now >= new DateTime(’13:30′) && $now <= new DateTime(’13:40′);
    $afternoon = $now >= new DateTime(’15:20′) && $now <= new DateTime(’15:45′);

    Any other time it will show:
    <h2>No streaming</h2>

  • Thanks so much

    So would that be

    $morning = $now >= new DateTime(‘<?php get_field(‘morning_start_time’); ?>’)

Viewing 4 posts - 1 through 4 (of 4 total)