Javascript Date format(dateFormat)
Date.prototype.format = function (dateFormat) { var day = this.getDate(); var month = this.getMonth() + 1; var year = this.getFullYear(); if (dateFormat === "dd/mm/yyyy") {/*from www . j a v a2 s. c o m*/ return '{0}/{1}/{2}'.format(day, month > 9 ? month : '0' + month, year); } }; String.prototype.format = function () { var args = arguments; return this.replace(/{(\d+)}/g, function (match, number) { return typeof args[number] != 'undefined' ? args[number] : match ; }); }