javascript extract date from string

Solutions on MaxInterview for javascript extract date from string by the best coders in the world

showing results for - "javascript extract date from string"
Imogen
22 Jul 2018
1function getDate(d)
2{
3    var day, month, year;
4
5    result = d.match("[0-9]{2}([\-/ \.])[0-9]{2}[\-/ \.][0-9]{4}");
6    if(null != result) {
7        dateSplitted = result[0].split(result[1]);
8        day = dateSplitted[0];
9        month = dateSplitted[1];
10        year = dateSplitted[2];
11    }
12    result = d.match("[0-9]{4}([\-/ \.])[0-9]{2}[\-/ \.][0-9]{2}");
13    if(null != result) {
14        dateSplitted = result[0].split(result[1]);
15        day = dateSplitted[2];
16        month = dateSplitted[1];
17        year = dateSplitted[0];
18    }
19
20    if(month>12) {
21        aux = day;
22        day = month;
23        month = aux;
24    }
25
26    return year+"/"+month+"/"+day;
27}
queries leading to this page
date from string javascriptjavascript extract monh frm date stringjs date extract dateget javascript date from stringhow to get date from a string in jshow to extract date in jsextract date from string jsturn string into date object javascriptextract date from string nodereget date from string jshow to convert string date format in jshow to extract date from datetime string in javascriptjs get date from stringget string from date javascriptextract date from datestring jsextract date from javascriptextract date from string in javascripthow to extract date from date 28 29 jsextract date in jsjavascript get date from stringget date value from string javascripthow to get date from a sentence javascripthow to get date from string javascriptget date time from string javascriptgrab date from string jsjs get datefrom stringpull date from a string javascriptjavascript 2b string from dateget js date from stringget date from date string javascriptget a date from a string javascriptconvert date to date object javascripthow to extract dates dates from string javascriptjavascript read date from stringextract date in string jsextract only date from a given datetimes string in javascriptjavascript get new date from stringget date from string javascripthow to extract date in javascriptget date from a string in javascriptextract date from string javascriptjavascript extract date from stringextract time as a string from js date objectget date string from date javascripthow to extract date time and day from string in javascriptget str from date jshow to extract dates from string in javascripthow to convert string datetime to date in jsextract date from text jshow to convert a string into date and time format in jsextract date from text javascriptjavascript extract datetime from stringget date from string in javascripthow to get date from string in javascriptjavascript extract date from string