Software, your way.
How To Get Good Custom Software
(Download)
(PDF)
burger menu icon
WillMaster

WillMaster > LibraryWeb Page and Site Features

FREE! Coding tips, tricks, and treasures.

Possibilities weekly ezine

Get the weekly email website developers read:

 

Your email address

name@example.com
YES! Send Possibilities every week!

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: 8 May 2024, 23:20 (11:20 PM)

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.

  1. The timezone designation where your office is located.

  2. 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:

  1. Go to the Willmaster Timezone Designations page.

  2. Tap the name of the continent you live on or the oceanic area you live within.

  3. 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:

  1. Go to the Formatting Date and Time page and use the generator.

  2. Tap the individual item formatting links to create your format. Manually adjust the format in the text field as desired.

  3. 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:

  1. Replace America/Chicago with the timezone designation you determined at the Timezone Designation section further above.

  2. 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

Was this article helpful to you?
(anonymous form)

Support This Website

Some of our support is from people like you who see the value of all that's offered for FREE at this website.

"Yes, let me contribute."

Amount (USD):

Tap to Choose
Contribution
Method

All information in WillMaster Library articles is presented AS-IS.

We only suggest and recommend what we believe is of value. As remuneration for the time and research involved to provide quality links, we generally use affiliate links when we can. Whenever we link to something not our own, you should assume they are affiliate links or that we benefit in some way.

How Can We Help You? balloons
How Can We Help You?
bullet Custom Programming
bullet Ready-Made Software
bullet Technical Support
bullet Possibilities Newsletter
bullet Website "How-To" Info
bullet Useful Information List

© 1998-2001 William and Mari Bontrager
© 2001-2011 Bontrager Connection, LLC
© 2011-2024 Will Bontrager Software LLC