Hello I have to convert a date like D/M/YYYY
to YYYY/MM/DD
Ex : 1/6/2015 --> 2015/06/01 not 2015/6/1
I have some conditions to be met :
When it convert the month like Jan "1" must give : 01, Feb "2" must give : 02 etc
I have to use
Date()
var st = "D/M/YYYY" var dt = new Date(st); var maFonction = function(userdate) { var day = st.getDate(); var month = st.getMonth(); var year = st.getFullYear(); var maDate = year + "/" + day + "/" + month; return maDate; } console.log(maFonction(st));
I tried but it doesn't works.