# Show the Site Time in the Admin Bar

> Displays the current time in the site's timezone in the admin bar, which helps when scheduling posts from another timezone.

- Type: PHP
- Runs: Run everywhere
- Category: [Admin](https://wpide.com/library/category/admin/)
- Tags: admin, admin-bar, timezone
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/site-time-in-admin-bar/

## Code

```php
add_action( 'admin_bar_menu', function ( $wp_admin_bar ) {
    if ( ! current_user_can( 'edit_posts' ) ) {
        return;
    }

    $timezone = wp_timezone_string();

    $wp_admin_bar->add_node( array(
        'id'     => 'wpide-site-time',
        'parent' => 'top-secondary',
        'title'  => esc_html( wp_date( get_option( 'time_format' ) ) ),
        'href'   => current_user_can( 'manage_options' ) ? admin_url( 'options-general.php#timezone_string' ) : false,
        'meta'   => array( 'title' => 'Site time (' . $timezone . ')' ),
    ) );
}, 1 );
```

## Notes

The time is set when the page loads; it does not tick.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Show the Site Time in the Admin Bar" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
