programming-examples/js/Date/Write a JavaScript function to get the current date..js
2019-11-15 12:59:38 +01:00

12 lines
312 B
JavaScript

var curday = function(sp){
today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //As January is 0.
var yyyy = today.getFullYear();
if(dd<10) dd='0'+dd;
if(mm<10) mm='0'+mm;
return (mm+sp+dd+sp+yyyy);
};
console.log(curday('/'));
console.log(curday('-'));