2015-03-28 17:46:05
<script>//gets the current system time Var now=new date ();//Gets May 1, 2015 time var date1=new date (' 2015/5/1 ');//The current date is the number of milliseconds from the initial date var s1= Now.gettime ();//May 1, 2015 number of milliseconds from the initial date var s2=date1.gettime ();//To May 1, 2015 How many milliseconds s3=s2-s1;//to May 1, 2015 How many days alert (' There is also ' +math.ceil (s3/(1000*60*60*24) + ' Day ') from May 1, 2015; </script>
There are some books on the introduction of the parse, but now almost no use of the parse, almost all with gettime, but no matter which method, the idea of the problem is still unchanged
If you write more carefully:
<script> //using the Date Date object to complete, the page shows how many days until May 1, 2015//Gets the current system time Var now=new Date ();//Get May 1, 2015 time var date1= New Date (' 2015/5/1 ');//The current date is the number of milliseconds from the initial date var s1=now.gettime ();//May 1, 2015 the number of milliseconds from the initial date var s2=date1.gettime ();/ The number of milliseconds to May 1, 2015 s3=s2-s1;//to May 1, 2015 How many days VAR Diff=math.ceil (s3/(1000*60*60*24)), if (diff>1) {alert (' Until May 1, 2015 there is ' +diff+ ' Day ');} else if (diff==1) {alert (' Tomorrow is May 1, 2015 ');} else if (diff==0) {alert (' Today is May 1, 2015 ');} Else{alert (' Silly, May 1, 2015 has passed! ');} </script>
The number of days from the current time to a fixed date, such as: How many days before the page pops up to May 1, 2015