The Date object is used to process dates and times.
Syntax for creating a Date object: var mydate=new date ()
Note: The Date object automatically saves the current date and time as its initial value.
The instance code is as follows:
Create an array to output the name of the week and month, for example:
<script type= "Text/javascript" >var d=new Date () var month=new Array (a) month[0]= "January" month[1]= "February" month[2]= "March" month[3]= "April" month[4]= "may" month[5]= "June" month[6]= "July" month[7]= "August" month[8]= " September "month[9]=" October "month[10]=" November "month[11]=" December "document.write (" the Month is "+ month[ D.getmonth ()]) //output: The month is February </script>
Common methods for date objects:
Date (): Returns the day and time
GetDate (): Returns a day in one months from a Date object (1~31)
GetDay (): Returns a day of the week from a Date object (0~6)
GetMonth (): Returns the month from the Date object (0~11)
getFullYear (): Returns the year from a date object with four-digit numbers
GetHours (): Returns the hour of the Date object (0~23)
Getminutes (): Returns the minute of the Date object (0~59)
Getseconds (): Returns the number of seconds of the Date object (0~59)
Getmilliseconds (): Returns the milliseconds of the Date object (0~999)
Date Object-current system time. Instance