It seemed like such a simple thing that someone must have built one already, but alas, no. We recently needed to replace an old-school world clock from our archaic intranet (it was built in asp classic, folks... that's right).
The requirements were pretty simple:
- List multiple locations around the world
- Show the current time in those locations
- Don't look terrible (you'd understand if you saw the old one)
After searching the interwebs for something that would meet our needs without completely over-engineering the problem, we couldn't find anything. At this point, I leaned back, sipped some coffee contemplatively and thought to myself, "Self, this is nuts. Let's just build something". Admittedly, I'm a little predisposed to want to build things!
In the end, I crafted a small script that loads the list of locations and time zones from a SharePoint list, and then displays them in a simple table. The time zone magic is handled with the awesome moment.js and moment-timezone.js libraries.
Easy. Peasy. World clock.
How to use the script
- Create a SharePoint list on the site where you'll show the clock
- It should have a Title field by default
- Add a required text field called "Country"
- Add a required text field called "Timezone"
- Add your locations to the list
- Upload the script below (or from GitHub) to your SharePoint site
- Create a new SharePoint page
- Add a content editor web part to the page
- Stick the path of the script you just uploaded into the URL field of the web part
- Optionally, you can set the "Chrome Type" to "None"
- Save and publish your page