JavaScript program for date methods

 var now=new Date();

document.write(now+"<--Date()<br>");

var now=new Date();

document.write(now.toDateString()+"<--Date()<br>");

var now=new Date();

document.write(now.getFullYear()+ "<--getFullYear()<br>");

var now=new Date();

document.write(now.getMonth()+"<--getMonth()<br>");

var now=new Date();

document.write(now.getDate()+"<--getDate()<br>");

var now=new Date();

document.write(now.getDay()+"<--getDay()<br>");

var now=new Date();

document.write(now.getHours()+"<--getHours()<br>");

var now=new Date();

document.write(now.getMinutes()+ "<--getMinutes()<br>");

var now=new Date();

document.write(now.getSeconds()+ "<--getSeconds()<br>");

var now=new Date();

document.write(now.getMilliseconds()+

"<--getMilliseconds()<br>");

var now=new Date();

now.setDate(20);

document.write(now+"<--setDate()<br>");

var now=new Date();

now.setFullYear(2025);

document.write(now+"<--setFullYear()<br>");

var now=new Date();

now.setMonth(8);

document.write(now+"<--setMonth()<br>");

var now=new Date();

now.setHours(22);

document.write(now+"<--setHours()<br>");

var now=new Date();

now.setMinutes(20);

document.write(now+"<--setMinutes()<br>");

var now=new Date();

now.setSeconds(59);

document.write(now+"<--setSeconds()<br>");

var now=new Date();

now.setMilliseconds(200);

document.write(now+"<--setMilliseconds()<br>");


Output





Comments