Every line of 'javascript date parse format yyyy-mm-dd hh mm ss' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
180 export function dateFormat(timestamp, format = 'yyyy-MM-dd hh:mm:ss') { 181 timestamp = timestamp.length === 13 ? timestamp : timestamp * 1000 182 let date = new Date(timestamp) 183 let args = { 184 'M+': date.getMonth() + 1, 185 'd+': date.getDate(), 186 'h+': date.getHours(), 187 'm+': date.getMinutes(), 188 's+': date.getSeconds() 189 } 190 if (/(y+)/.test(format)) { 191 format = format.replace( 192 RegExp.$1, 193 (date.getFullYear() + '').substr(4 - RegExp.$1.length) 194 ) 195 } 196 for (var i in args) { 197 let n = args[i] 198 if (new RegExp('(' + i + ')').test(format)) { 199 format = format.replace( 200 RegExp.$1, 201 RegExp.$1.length === 1 ? n : ('00' + n).substr(('' + n).length) 202 ) 203 } 204 } 205 return format 206 }
105 export function parseDate(d: string): Date { 106 const matches = d.match(/\d+/); 107 return new Date(parseInt(matches![0], 10)); 108 }
11 format (fmt = 'yyyy-MM-dd HH:mm:ss') { 12 const obj = { 13 'y+': this.date.getFullYear(), 14 'M{2}': this._paddingZero(this.date.getMonth() + 1), 15 'd{2}': this._paddingZero(this.date.getDate()), 16 'H{2}': this._paddingZero(this.date.getHours()), 17 'h{2}': this._paddingZero(this.date.getHours() % 12), 18 'm{2}': this._paddingZero(this.date.getMinutes()), 19 's{2}': this._paddingZero(this.date.getSeconds()), 20 'M': this.date.getMonth() + 1, 21 'd': this.date.getDate(), 22 'H': this.date.getHours(), 23 'h': this.date.getHours() % 12, 24 'm': this.date.getMinutes(), 25 's': this.date.getSeconds(), 26 'W': this.date.getDay() 27 } 28 for (let [key, ] of Object.entries(obj)) { 29 const regexp = new RegExp(`(${key})([^a-zA-Z])?`) 30 if (regexp.test(fmt)) { 31 fmt = fmt.replace(RegExp.$1, obj[key]) 32 } 33 } 34 return fmt 35 }
46 function parseDate(date) { 47 var re = date.match("([0-9]+)-([0-9]+)-([0-9]+) ([0-9]+):([0-9]+):.*"); 48 return (re[2] + '/' + re[3] + '/' + re[1] + ' ' + re[4] + ':' + re[5]); 49 }
567 function parseDate(date) { 568 if (date) { 569 try { return new Date(Date.parse(date)); } 570 catch (e) { /* ignore invalid dates */ } 571 } 572 }
49 function parseDateFormat2(str) { 50 // 2010/31/2 51 const m = str.match(/^(\d{4})[/\s.\-,](\d{1,2})[/\s.\-,](\d{1,2})$/); 52 return (m) ? new Date(m[1], m[2] - 1, m[3]) : NaN; 53 }
120 function parseDate (date) { 121 date = date.split('-') 122 123 var year = parseInt(date[0]) 124 var month = parseInt(date[1]) - 1 125 var day = parseInt(date[2]) 126 127 return new Date(year, month, day) 128 }
46 function parseDate(str) { 47 if (Y.Lang.isNull(str) || Y.Lang.isUndefined(str)) 48 return null; 49 var parts = str.split(/[- :]/); 50 if ( parts.length < 3 ) 51 return null; 52 while ( parts.length < 6 ) 53 parts.push(0); 54 return new Date(parts[0], parts[1]-1, parts[2], parts[3], parts[4], parts[5]); 55 }
110 function parseDate(string) { 111 var y = string.substring(0, 4); 112 var m = string.substring(4, 6); 113 var d = string.substring(6, 8); 114 return new Date(y, m, d); 115 }
8 static formatDateYYYYMMDD(date) { 9 return DateFormatter.format(date, "yyyy-MM-dd"); 10 }