Interview GURU

What is the use of a Date object in JavaScript?

The JavaScript date object can be used to get a year, month and day. You can display a timer on the webpage by the help of JavaScript date object.

function test()  
  var date=new Date();    
  var day=date.getDate();    
  var month=date.getMonth()+1;    
  var year=date.getFullYear();    
  document.write("<br>Date is: "+day+"/"+month+"/"+year);