$(".date").text(function(i,v){
var m = v.match(/(\d+)\.(\d+)/);
if ( m ) {
var date = new Date( (new Date()).getFullYear(), --m[2], m[1]);
return date.toDateString();
}
});
小提琴:http: //jsfiddle.net/jonathansampson/CuDdD/
如果您想要完整的月份名称,则需要提供自己的月份数组:
var m, mo = ['January','February','March', 'April', 'May', 'June',
'July', 'August', 'September','October','November','December'];
$(".date").text(function(i,v){
if ( m = v.match(/(\d+)\.(\d+)/) ) {
return m[1] + " " + mo[ --m[2] ] + " " + (new Date()).getFullYear();
}
});
小提琴:http: //jsfiddle.net/jonathansampson/CuDdD/2/