10 examples of 'javascript parse date format dd-mmm-yyyy' in JavaScript

Every line of 'javascript parse date format dd-mmm-yyyy' 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.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
105export function parseDate(d: string): Date {
106 const matches = d.match(/\d+/);
107 return new Date(parseInt(matches![0], 10));
108}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

46function 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}
120function 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}
567function parseDate(date) {
568 if (date) {
569 try { return new Date(Date.parse(date)); }
570 catch (e) { /* ignore invalid dates */ }
571 }
572}
49function 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}
17public static parse(date: any): Date {
18 return moment(date).toDate();
19 //return moment.utc(date).add('milliseconds', timeZoneOffset).toDate();
20}
24function parseDate(dateCode) {
25 const {y, m, d, H, M, S} = XLSX.SSF.parse_date_code(dateCode)
26
27 return new Date(`${y}/${m}/${d} ${H}:${M}:${S}`).getTime()
28}
413function parseDate(sDate) {
414 return {
415 year: parseDateArgument(sDate.substr(0, 4)),
416 month: parseDateArgument(sDate.substr(4, 2)),
417 day: parseDateArgument(sDate.substr(6, 2))
418 };
419}
243function parseDate(sDate) {
244 return {
245 year: parseInt(sDate.substr(0, 4)),
246 month: parseInt(sDate.substr(4, 2)),
247 day: parseInt(sDate.substr(6, 2))
248 };
249}
46function 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}

Related snippets