Here you can find the source of toDate(pattern = 'YYYY-MM-DD')
String.prototype.toDate = function (pattern = 'YYYY-MM-DD') { let date = new Date()/*from w w w . j a v a 2 s . c o m*/ if (pattern.indexOf("YYYY") > -1) { const yearIndex = pattern.indexOf("YYYY") date.setFullYear(this.substring(yearIndex,yearIndex+4)) } if(pattern.indexOf("MM")>-1){ const monthIndex = pattern.indexOf("MM") date.setMonth(this.substring(monthIndex,monthIndex+2)-1) } if(pattern.indexOf("DD")>-1){ const dayIndex = pattern.indexOf("DD") date.setDate(this.substring(dayIndex,dayIndex+2)) } if(pattern.indexOf("HH")>-1){ const hourIndex = pattern.indexOf("HH") console.log('hehe') date.setHours(this.substring(hourIndex,hourIndex+2)) } if(pattern.indexOf("mm")>-1){ const minutesIndex = pattern.indexOf("mm") date.setMinutes(this.substring(minutesIndex,minutesIndex+2)) } if(pattern.indexOf("SS")>-1){ const secondsIndex = pattern.indexOf("SS") date.setSeconds(this.substring(secondsIndex,secondsIndex+2)) } return date }
String.prototype.toDate = function() { return new Date(this.slice(0,15)); };
String.prototype.toDate = function() var date, parts, year, month, day, hours, minutes, seconds, ms; if (parts = this.match(/^([0-9]{4})\-([0-9]{2})\-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(\.([0-9]{1,3}))?(Z|([-+0-9:]{6}))$/)) date = Date.parse(this); if (isNaN(date)) year = parts[1]; ...
String.prototype.toDate = () =>{ var from = $(this).val().split("/"); var f = new Date(from[2], from[1] - 1, from[0]); return f;
String.THROW_WHEN_INVALID_DATE = true String.prototype.toDate = function(dateIsOmittable, monthIsOmittable) { var date = null; var str = "0000-00-00"; if (/^\d{4}-\d{2}-\d{2}$/.test(this)) str = new String(this); else if (dateIsOmittable && /^\d{4}-\d{2}$/.test(this)) str = this + "-01"; else if (dateIsOmittable && monthIsOmittable && /^\d{4}$/.test(this)) ...
String.prototype.toDate = function(str) { var m = this.match(/(\d+)-(\d+)-(\d+)\s+(\d+):(\d+):(\d+)/); return new Date(+m[1], +m[2] - 1, +m[3], +m[4], +m[5], +m[6]);
String.prototype.toDateFormat = function (format) { return this.parseToDate().toDateFormat(format); };
if (!window.console) { console = { log: function (msg) { }; }; String.prototype.toDateFromAspNet = function () { var dte = eval("new " + this.replace(/\ dte.setMinutes(dte.getMinutes() - dte.getTimezoneOffset()); ...
String.prototype.toDateFromAspNet = function () { var dte = eval("new " + this.replace(/\ dte.setMinutes(dte.getMinutes() - dte.getTimezoneOffset()); return dte; };