programming-examples/js/Date/Write a JavaScript function to get the day of the month, 2 digits with leading zeros..js

10 lines
226 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
function day_of_the_month(d)
{
return (d.getDate() < 10 ? '0' : '') + d.getDate();
}
d= new Date();
console.log(day_of_the_month(d));
d= new Date(2015, 10, 1);
console.log(day_of_the_month(d));