Tuesday, March 02, 2004

Win a Date with Javascript

So I have a couple of pages on our site that use javascript to display the date and or time. And of course none of them have the same format. Right now each page has a different javascript to display the date. And if course that isn't very modular. So I wrote an fairly complete javascript function, that if you tell it the format you want it in it will give today's date in the format.
Here are the formats available:

shortdate: 3/2/2004
shortdatetime: 3/2/2004 10:35
shortdateUTCtime: 3/2/2004 18:35:27
longdate: March 2, 2004
longdatetime: March 2, 2004 10:38
longdateUTCtime: March 2, 2004 18:40:12
longweekday Tuesday, March 2, 2004
longweekdaytime Tuesday, March 2, 2004 10:41
longweekdayUTCtime Tuesday, March 2, 2004 18:42:18

You can download the source code here. Download the text file and change it to a iDate.js. The file is commented on how to use it. Feel free to use it in your projects.

No comments: