jquery/javascript convert date string to date

If you’re running with jQuery you can use the datepicker UI library’s parseDate function to convert your string to a date:

var d = $.datepicker.parseDate("DD, MM dd, yy",  "Sunday, February 28, 2010");

and then follow it up with the formatDate method to get it to the string format you want

var datestrInNewFormat = $.datepicker.formatDate( "mm/dd/yy", d);

If you’re not running with jQuery of course its probably not the best plan given you’d need jQuery core as well as the datepicker UI module… best to go with the suggestion from Segfault above to use date.js.

HTH

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)