
What's the Date object using JavaScript?

Hi,
The Date object is used to work with dates and times. Date objects are created with the Date() constructor.
JavaScript has an inbuilt support for dates and times with its Date object. The methods of the Date object return various values associated with date and time.
To start working with dates and time, we first initialize a variable and assign it a value with the new operator and the Date() constructor. The main function of the new operator with Date() constructor is to create a new date object that is stored in the variable. Here is the code:
<script type="text/javascript">
<!--
var d = new Date();
var nhours=d.getHours();
var nmins=d.getMinutes();
var nsecn=d.getSeconds();
var curr_date = d.getDate();
var curr_month = d.getMonth();
var curr_year = d.getFullYear();
document.write(curr_date + "-" + curr_month + "-" + curr_year);
document.write("<p>"+""+"</p>");
document.write( nhours+"-"+nmins+"-"+nsecn);
//-->
</script>
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.