Voglio ottenere la data odierna nel formato gg-mm-aaaaJavascript ottenere data in formato
Sto usando var currentDate = new Date(); document.write(currentDate);
Non riesco a capire come formattarlo.
ho visto gli esempi var currentTime = new Date(YY, mm, dd);
e currentTime.format("mm/dd/YY");
Entrambi i quali non funzionano
ho finalmente avuto una data correttamente formattata utilizzando
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1;//January is 0!`
var yyyy = today.getFullYear();
if(dd<10){dd='0'+dd}
if(mm<10){mm='0'+mm}
var today = mm+'/'+dd+'/'+yyyy;
document.write(today);'`
Questo sembra molto complesso per un compito così semplice .
C'è un modo migliore per ottenere la data di oggi in dd/mm/yyyy
?
Lo farei manualmente 'var d = new Date(); \t \t \t \t var s = new String(); \t \t \t \t s = (d.getHours() + "-" + d.getMinutes() + "-" + d.getSeconds() + "" + d.getDate() + "-" + d.getMonth() + "-" + d.. GetFullYear()) toString(); '. Riferimento: http://www.w3schools.com/jsref/jsref_obj_date.asp – Nav