datejs – open-source JavaScript Date Library

datejs is an open source Javascript library which makes working with date and time comfortable in javascript.

I guess following are the things which are generally required:

1. Formatting date and time
2. Adding, subtracting date and times.
3. comparing dates.
3. Parsing a string into date
4. Figure out today’s Day.

Some syntactic overview of datejs below:

 
 
 // native .toString() functionality
Date.today().toString();
Date.today().toString("M/d/yyyy"); // 19-Nov-2007
new Date().toString("HH:mm");      // 18:45
 
// Get today’s date
Date.today();
 
// Add 5 days to today
Date.today().add(5).days();
 
// Get Friday of this week
Date.friday();
 
// Get March of this year
Date.march();
 
// Is today Friday?
Date.today().is().friday();  // true|false
 
// What day is it?
Date.today().getDayName();
 
 
var today = Date.today();
var past = Date.today().add(-6).days();
var future = Date.today().add(6).days();
 
 
Date.compare(today, future);                    // -1
Date.compare(today, new Date().clearTime());    // 0
Date.compare(today, past)                       // 1
 
 
// July 8?
Date.parse(‘July 8?);
 
// With a year?
Date.parse(‘July 8th, 2007?);
 
// And time?
Date.parse(‘July 8th, 2007, 10:30 PM’);
 
 

Get started with datejs

Download from here.

See full documentation at http://code.google.com/p/datejs/wiki/APIDocumentation

Most Commented Posts

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments

No comments yet.

Leave a comment

(required)

(required)