Best JavaScript Date Parser & Formatter?

53,310

Solution 1

If you already use jqueryUI on the page, than $.datepicker has parseDate() and formatDate() functions that enough in most cases. As for DateJS - profile yu code and you'll see how it baggy and how much time it spends in handling exception

Solution 2

I've found the jQuery Globalization Plugin date parsing to work best. Other methods had cross-browser issues and stuff like date.js had not been updated in quite a while.

You also don't need a datePicker on the page. You can just call something similar to the example given in the docs:

$.parseDate('yy-mm-dd', '2007-01-26');

Solution 3

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 functions 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.

Share:
53,310
Elijah Manor
Author by

Elijah Manor

I am a Christian and a family man. I'm the President of Manorism, Inc. and a PluralSight Author. I specialize in providing front-end web development training (JavaScript/jQuery/HTML5). I'm a Microsoft Regional Director, Microsoft ASP.NET MVP, ASPInsider, and IE userAgent. I enjoy blogging at http://elijahmanor.com and tweeting (@elijahmanor) about the things I learn.

Updated on July 09, 2022

Comments

  • Elijah Manor
    Elijah Manor almost 2 years

    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?

  • Liam
    Liam about 12 years
    the date.js library seems buggy and I had problems implementing it while using the jquery ui datepicker, this seems a better supported solution.
  • Varun
    Varun almost 12 years
    @Liam this has only date what in case we want some time also to come with it....