JSFiddle - React, Tailwind, and code Playground

HTML

<span id="timeformat"></span>

JavaScript

//Create a known date string
var y = new Date(2013, 9, 25);
var lds = y.toLocaleDateString();

//search for the position of the year, day, and month
var yPosi = lds.search("2013");
var dPosi = lds.search("25");
var mPosi = lds.search("10");

//Sometimes the month is displayed by the month name so guess where it is
if(mPosi == -1)
{
    mPosi = lds.search("9");
    if(mPosi == -1)
    {
        //if the year and day are not first then maybe month is first
        if(yPosi != 0 && dPosi != 0)
        {
            mPosi = 0;
        }
        //if year and day are not last then maybe month is last
        else if((yPosi+4 <  lds.length) && (dPosi+2 < lds.length)){
            mPosi = Infinity;
        }
        //otherwist is in the middle
        else  if(yPosi < dPosi){
            mPosi = ((dPosi - yPosi)/2) + yPosi;            
        }else if(dPosi < yPosi){
            mPosi = ((yPosi - dPosi)/2) + dPosi;
        }   
    }
    
}


var formatString="";
var order = [yPosi, dPosi, mPosi];
order.sort(function(a,b){return a-b});

for(i=0; i < order.length; i++)
{
    if(order[i] == yPosi)
    {
        formatString += "YYYY/";
    }else if(order[i] == dPosi){
        formatString += "DD/";
    }else if(order[i] == mPosi){
        formatString += "MM/";
    }
}

formatString = formatString.substring(0, formatString.length-1);

$('#timeformat').html(formatString+" "+lds);