About JS Date acquisition to use the most basic date () method to get the date of the day
var d =new Date (); Defining Date Objects
var y=d.getfullyear (); Get year
var m=d.getmonth () +1; Returns the month (0 ~ 11) from the Date object, so add 1.
var dd=d.getdate (); Get Day
Get hours, minutes, and seconds in the same vein. Note: 1 seconds =1000 milliseconds
<! DOCTYPE html>#box {width:650px;height:80px;background: #ccc; Color:green;font-size:26px;text-align:center;line-height:80px;} </style> <script>window.onload=function(){ varObox=document.getelementbyid (' box '); functionShow () {//define function Show varD =NewDate (); vary=d.getfullyear (); varM=d.getmonth (+1); varDd=d.getdate (); varH=d.gethours (); varmm=d.getminutes (); vars=d.getseconds (); vart=y+ "Year" +m+ "month" +dd+ "Day" +h+ "+mm+" minute "+s+" seconds "; Obox.innerhtml=t;//Use the date innerHTML in the Div} setinterval (show,1000);//Timer (1: Call Show 2:1 seconds =1000 milliseconds to refresh)Show ();//The call to show function is to press the F5 refresh when the screen does not appear to be interrupted. } </script>JS Simple Date Acquisition (Beginner Basics)