Publishing Your Current Office Time
If you offer a telephone number for people to call, it is considerate to let them know what time it is at your office.
Providing the name of your timezone is good, too. Yet, with only a timezone indication, the caller will still need to do some mental arithmetic to determine your current time — or look it up on the internet.
The software you find further below will publish the current time at your office the moment your web page is loaded — independent of the time zone setting for the computer or device used to view your page.
Here is our current office time: 22 Dec 2024, 4:45 AM
The above example is published with my traditional 12‑hour AM/PM format. The software can display a 24‑hour format just as well.
You'll find live implementations at the Willmaster contact page and the Spam-free Form contact page.
The software is PHP. It will need two customizations.
-
The timezone designation where your office is located.
-
The format for publishing the date/time on your web page.
Timezone Designation
The software expects a timezone to be specified with a correctly-formatted PHP timezone designation.
The timezone designation for your geographical location can be looked up at the php.net list of supported timezones. Or, use this method, which is likely to be easier:
-
Go to the Willmaster Timezone Designations page.
-
Tap the name of the continent you live on or the oceanic area you live within.
-
Tap the name of the metropolitan areas for the region that is closest to you. You'll see the correctly-formatted timezone designation for PHP scripts.
Copy the timezone designation so you have it at hand when you're ready to customize the PHP script.
Date/Time Format
The software expects a date/time format to be specified.
The php.net date() manual can be used to create a date/time format. Or, use this method, which is likely to be easier:
-
Go to the Formatting Date and Time page and use the generator.
-
Tap the individual item formatting links to create your format. Manually adjust the format in the text field as desired.
-
Use the generator to test various date and time formats until the preview shows you exactly what you're looking for.
Copy the date/time format so you have it at hand when you're ready to customize the PHP script.
The PHP Script
The PHP script is designed to be inserted into your web page at the spot where you want your office time to be published.
Here is the script. Customization notes follow.
<?php /* December 3, 2018. Will Bontrager Software LLC, willmaster.com */ $OfficeTimezoneDesignation = 'America/Chicago'; $DateTimePublishingFormat = 'j M Y, g:i A'; $tzstore = date_default_timezone_get(); date_default_timezone_set($OfficeTimezoneDesignation); echo date($DateTimePublishingFormat); date_default_timezone_set($tzstore); ?>
There are two places to customize:
-
Replace
America/Chicago
with the timezone designation you determined at the Timezone Designation section further above. -
Replace
j M Y, g:i A
with the date/time format you determined at the Date/Time Format section further above.
Paste the PHP code into the source code of your web page at the exact spot where you want your office time published.
With your current office time published on your page, you demonstrate your consideration for your site visitors who wish to contact you at your office.
(This article first appeared with an issue of the Possibilities newsletter.)
Will Bontrager