Date formatting with jQuery

Pure JS

by Pankaj Sapkal

HTML

<span class="date">08-Aug-2012</span>
<span class="date">2012/08/Aug</span>
<span class="date">Monday, August 08, 2012</span>

JavaScript

$(document).ready(function () {
    $('span.date').each(function() { 
        var dateFormat = $(this).text()
        var dateFormat = $.datepicker.formatDate('yymm', new Date(dateFormat));
        //alert(dateFormat);
        $(this).html(dateFormat + "<br>");
    });
});