
JavaScript have date object for print the date. This date function prints the current date. We will also modify the date function by the overload the paramitas. We also show only date, time, year, second etc. This function is very help full for programmer. Now given bellow the date function code and also format the function and explain the code.
Some JavaScript date function:
• getFullYear
• getMonth
• getDate
• getHours
• getMinutes
• getSeconds
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript">
//print Date only
var myDate=new Date();
console.log("Fill Date: "+myDate);
//print formeted Date
var myDaye2 = new Date();
console.log("Fill Year: "+myDaye2.getFullYear());
console.log("Fill Month: "+myDaye2.getMonth());
console.log("Fill Date: "+myDaye2.getDate());
console.log("Fill Hours: "+myDaye2.getHours());
console.log("Fill Minutes: "+myDaye2.getMinutes());
console.log("Fill Seconds: "+myDaye2.getSeconds());
</script>
</body>
</html>
In this code first we declare the Date function and store the variable then print the value by “console.log”. Now again create date and store the another variable and get the full year, month date hours etc using the pre define function.