Posts

Showing posts from November, 2012

JavaScript library for Date formatting

Hi all, You must have faced situations where you need to convert a date string to a different object. The usual procedure is to first parse the string into a Date object of that language, specifying your formatting string. The next step is to convert the Date object back into a string specifying the new formatter. In order to do this in JavaScript, I came across two libraries which I thought to share with you. Moment.js which is freely distributable under the MIT license. You can download it from here . There are two versions. You can download the minified source if you need to save space. The following example shows how to use it to convert from one format to another. First include the javascript in your files. var oldFormatTime = moment('2012-10-01','YYYY-MM-dd'); var newFormatTime = oldFormatTime.parse('d-MM-YYYY'); So, the final output would be 1-10-2012 In addition to this, I also found the following library. Datejs is an open source