String.prototype.to = function () { var x = new Date(this.replace(/(\d+)(\w+?)(\d+)/, '$1 $2 $3')).getMonth() + 1, x = x < 10 ? '0' + x : x; return this.slice(-4) + x + this.slice(0, 2); }; alert('01Feb1945'.to());