Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript extract date from string

function getDate(d)
{
    var day, month, year;

    result = d.match("[0-9]{2}([-/ .])[0-9]{2}[-/ .][0-9]{4}");
    if(null != result) {
        dateSplitted = result[0].split(result[1]);
        day = dateSplitted[0];
        month = dateSplitted[1];
        year = dateSplitted[2];
    }
    result = d.match("[0-9]{4}([-/ .])[0-9]{2}[-/ .][0-9]{2}");
    if(null != result) {
        dateSplitted = result[0].split(result[1]);
        day = dateSplitted[2];
        month = dateSplitted[1];
        year = dateSplitted[0];
    }

    if(month>12) {
        aux = day;
        day = month;
        month = aux;
    }

    return year+"/"+month+"/"+day;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to remove duplicate object in array javascript 
Javascript :: build apk from react native 
Javascript :: iterate array in javascrpt 
Javascript :: light font color to dark background using javascript 
Javascript :: span change jquery 
Javascript :: change image src using jquery 
Javascript :: change select value jquery 
Javascript :: tribonacci sequence javascript 
Javascript :: preloader js code 
Javascript :: how to pip install jsonlines 
Javascript :: run onclick function once 
Javascript :: how to run javascript in chrome 
Javascript :: javascript two decimal places after division 
Javascript :: jquery check if all checkbox is not checked 
Javascript :: moment get day 
Javascript :: express-async-errors 
Javascript :: vscode rest api extention POST method 
Javascript :: axios middleware 
Javascript :: lowercase to uppercase in javascript 
Javascript :: express req get json 
Javascript :: javascript backwards loop array 
Javascript :: how to reade selected csv file data in node j s 
Javascript :: user input in js 
Javascript :: what is JSON TREE 
Javascript :: cart page url in shopify 
Javascript :: how to see node taints 
Javascript :: npm run build npm ERR! Missing script: "build" for firebase 
Javascript :: angular build production 
Javascript :: fetch get request 
Javascript :: react native filter list 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =