Dates and Javascript

Dates and timestamps and things of this sort have often been the bane of my existence when working with javascript. For whatever reason javascript never came out-of-the-box with handy dandy date utilities to make working with those types of variables painless. I'm slightly spoiled, because in PHP you can do just about anything with strtotime() and the formatting options of date(). PHP 5 tossed in the DateTime object and then things became really fun. Likewise, when I work in the world of Java there is SimpleDateFormat and the far superior Joda. Most of the time I just let these things do the grunt work when it comes to dates and I let Javascript feed off of their superiority.

Today I stumbled into Datejs, which is a Javascript library that takes from the best elements of the Java and PHP world, mixes them together and tacks on some excellent jQuery-style chaining to make what is by far the best date solution for Javascript I have seen to date. There are formatting features for outputting dates, conversion features for reading in dates, modification and comparison methods and best of all a series of chainable function to build dates, ie. Date.today().next().thursday();. How cool is that?!? I'm bundled this into just about everything I do, if I include jQuery or some other primary library into a project I expect to be tucking this in with it. Too often am I stuck with a date conundrum, so it's better to have this utility around.

Bottom line, if you're doing javascript work of any kind and haven't already found this gem - go download it now().

tags: javascript

Post Comment:

Comments are now closed.

Copyright © 2002-2010 Stan Lemon | Design by: styleshout