Time & Date JavaScript Code Snippets

These snippets all relate to time and dates. Some of them display only the month, others the entire year. Some highlight the current day or tell you when you entered the page. Other snippets display the current date or time according to the user’s time zone, or another time zone some other place in the world. The source code is available for all the snippets.

Results via Envato Market

World time script with unusual display. Cross-browser (IE4 shows additional visual effects). Shows the localtime of world-capitals in a way you have never seen before. Combines the latest mouseover, CSS-positioning and filter-techniques.

This small script displays a message depending on the time period of the day. This script resembles the one on Microsoft’s scripting web site.

This is a droplist displaying local time values from 12:00am – 12:00am in 15 minute increments and using Universal or GMT time values. Works great for storing absolute GMT time in a DB and displaying time relative to the user’s local time. Since I’m writing the HTML in JS, I have set the onChange event to display an alert of the GMT value behind the displayed value.