Title: time settings
Last modified: August 30, 2016

---

# time settings

 *  Resolved [norolex](https://wordpress.org/support/users/norolex/)
 * (@norolex)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/time-settings/)
 * Hi Bob,
 * Can the following example (food delivery service) be done:
 * TopBar #1 shows from Sunday 11pm till Tuesday 10am and displays ‘Closed until
   Tuesday 10am’
 * TopBar #2 shows every day from 10am till 2pm (except wen TopBar #1 is activated)
   and displays ‘Open for business’
 * TopBar #3 shows every day from 2pm til 5pm (except wen TopBar #1 is activated)
   and displays ‘Closed until 5pm’
 * TopBar #4 shows every day from 5pm till 8pm (except wen TopBar #1 is activated)
   and displays ‘Rush hour – up to 1 hour wait’
 * TopBar #5 shows every day from 8pm till 11pm (except wen TopBar #1 is activated)
   and displays ‘Open for business’
 * Thank you for yor help and best regards,
    Willi
 * [https://wordpress.org/plugins/wp-topbar/](https://wordpress.org/plugins/wp-topbar/)

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

 *  Plugin Author [rfgoetz](https://wordpress.org/support/users/rfgoetz/)
 * (@rfgoetz)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/time-settings/#post-6862837)
 * Sure… Create one TopBar. Then use code like this in the PHP tab, in the BEFORE
   section.
 * You might need to adjust the logic in the statements to meet your requirements.
 * This will take the TopBar you create and modify the text being shown based on
   the DATE and TIME.
 * Let me know if this works for you,
 * Bob
    ———————-
 *     ```
       $d=date('w');  /* 0 (for Sunday) through 6 (for Saturday) */
       $h=date('G');  /* 24-hour format of an hour without leading zeros */
       switch ($d) {
           case 1: /* Monday */
                $wptbOptions['bar_text'] = 'Closed until Tuesday 10am';
                break;
           case 0: /* Sunday */
                if ($h > 22) {
                   $wptbOptions['bar_text'] = 'Closed until Tuesday 10am';
                   break;
                }
            default:
               if ($h < 10) {
                   $wptbOptions['bar_text'] = 'Closed until 10am';
                }
               elseif ($h < 14) {
                   $wptbOptions['bar_text'] = 'Closed until 5pm';
                }
               elseif ($h < 20) {
                   $wptbOptions['bar_text'] = 'Rush hour - up to 1 hour wait';
                }
               elseif ($h < 23) {
                   $wptbOptions['bar_text'] = 'Open for business';
               }
               else
                   if ($d == 6) {
                       $wptbOptions['bar_text'] = 'Closed until Tuesday 10am';
                   }
                   else {
                       $wptbOptions['bar_text'] = 'Closed until 10am tomorrow';
                   }
       }
       ```
   
 *  Thread Starter [norolex](https://wordpress.org/support/users/norolex/)
 * (@norolex)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/time-settings/#post-6863019)
 * Hi Bob,
 * This works but it is a few hours off.
    Maybe because of Timezone? What can be
   added to offset the time?
 * It is now 15:30 in Switzerland but TopBar shows ‘Closed until 10:00’
    It should
   show ‘Closed until 17:00’
 * Thank you very much and best regards,
    Willi
 * PS: I changed h to H to make it 24 hour format but it was also off with h before
 *  Plugin Author [rfgoetz](https://wordpress.org/support/users/rfgoetz/)
 * (@rfgoetz)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/time-settings/#post-6863025)
 * If you go to the Debug tab, you’ll see a Time Check Section:
    Mine looks like
   this:
 *     ```
       Time Check:
       Server Timezone: UTC
       Current Time: 12/19/2015 08:24
       Current Time (GMT): 12/19/2015 16:24
       WordPress GMT Offset: -8
       ```
   
 * I’ve set my time (Shown as Current Time) to be pacific, where I live. Yours may
   be different. So, you’ll need to adjust the hours in the sample code to offset
   from your server time.
 * You should also check your WordPress time in WordPress|Settings|General.
 * A quick cheat might be to add this line as the last line in the code:
 * `$wptbOptions['bar_text'] = $h;`
 * This will just display the current hour in the TopBar text. Then you can just
   calculate the offset from your watch’s time and adjust the code as appropriate.
 * Last, you can set the default timezone in the sample code – see this for instructions:
   [http://php.net/manual/en/function.date.php](http://php.net/manual/en/function.date.php)
 * Bob
 *  Thread Starter [norolex](https://wordpress.org/support/users/norolex/)
 * (@norolex)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/time-settings/#post-6863107)
 * Hi Bob,
 * You can mark this as resolved, it all works great.
 * Thanks again for your help
    Willi

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

The topic ‘time settings’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-topbar_706d6d.svg)
 * [WP-TopBar](https://wordpress.org/plugins/wp-topbar/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-topbar/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-topbar/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-topbar/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-topbar/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-topbar/reviews/)

## Tags

 * [daily](https://wordpress.org/support/topic-tag/daily/)
 * [time](https://wordpress.org/support/topic-tag/time/)

 * 4 replies
 * 2 participants
 * Last reply from: [norolex](https://wordpress.org/support/users/norolex/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/time-settings/#post-6863107)
 * Status: resolved