wordpress - PHP: Show content at certain time -


new php , wordpress.

i'm trying show different content @ times (bst).

e.g breakfast content: 8am, lunch content 1pm

how go creating if loop show content based on current time?

below content breakfast.

<?php  $rows = get_field('breakfast'); $row_count = count($rows); $i = rand(0, $row_count - 1);  ?>  <h1> <?php echo $rows[ $i ]['dish_name']; ?> </h1> <p> <?php echo $rows[ $i ]['dish_description'];  ?> </p> <h3> served<span><?php echo $rows[ $i ]['time_served'];  ?></span> </h3> 

done it. if can done better please let me know.

<?php  date_default_timezone_set('bst');  $currenttime = time();  $breakfast = strtotime("11:30 am"); ?>  <?php if ($currenttime > $breakfast): ?>         <h1>             <?php echo $rows[ $i ]['dish_name']; ?>         </h1>         <p>            <?php echo $rows[ $i ]['dish_description'];  ?>         </p>         <h3>             served<span><?php echo $rows[ $i ]['time_served'];  ?></span>         </h3>     } <?php endif; ?> 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -