time regular expression code example

Example 1: display the link when time matching

<div id="radio-online">
    <p><a class="<?php echo $wlsgDayToggle; ?> <?php echo $wlsgTimeToggle; ?>" href="#" title="Online! Listen Now!" target="_blank">Online! Listen Now!</a></p>
    <p><a class="<?php echo $ucrDayToggle; ?> <?php echo $ucrTimeToggle; ?>" href="#" title="Online! Listen Now!" target="_blank">Online! Listen Now!</a></p>
</div>

Example 2: display the link when time matching

<?php 
    // Variables
    $h = date('G');
    $m = date('i');
    $d = date('l');

    //WLSG Schedule
    if ($d != 'Monday') $wlsgDayToggle = 'radio-offline';
    if ($h > 0) $wlsgTimeToggle = 'radio-online';
    if ($h < 1) $wlsgTimeToggle = 'radio-online';
    else $wlsgTimeToggle = 'radio-offline';

    //UCR Schedule
    if ($d != 'Sunday') $ucrDayToggle = 'radio-offline';
    if ($h > 23) $ucrTimeToggle = 'radio-online';
    if ($m > 40) $ucrTimeToggle = 'radio-online';
    if ($m < 59) $ucrTimeToggle = 'radio-online';
    else $ucrTimeToggle = 'radio-offline';
?>

Tags:

Misc Example