views:

5978

answers:

4

Since I've started to use jQuery, I have been doing a lot more JavaScript development.

I have the need to parse different date formats and then to display them into another format.

Do you know of any good tool to do this?

Which one would you recommend?

+22  A: 

A good library for parsing dates is this. Do you know the format of the dates before hand though, or are they user input?

Craig
This was very helpful ... especially considering that there seems to be some discrepancy between the native Date.parse in firefox and chrome.
jerhinesmith
This library is pretty comprehensive and a bit heavy, but it will parse just about anything. Note that if you have a specific format you want to parse, be sure to use the parseExact method. The standard parse method is pretty expensive since it has to try tons of different formats.
fullware
+1  A: 

Ext.Date. It uses the same formatting codes as PHP's date() function, but it also lets you parse in a specific format (which PHP doesn't do).

JW
+3  A: 

Take a look to this very good article: JavaScript date formatting benchmarks

CMS
+1  A: 

Just another option (which I wrote - full disclosure):

DP_DateExtensions Library

Supports date/time formatting, date math (add/subtract date parts), date compare, date parsing, etc. It's liberally open sourced.

I really like Date.js but find some of the syntax cumbersome. Most of the functions in mine are based (at least in part) on the rich set of fuctions in CFML - some people may find it a bit more comfortable.

No reason to consider it if you're already using a framework (they're all capable), but if you just need to quickly add date manipulation to a project give it a chance.

Jim Davis