<span id="Label3"></p><p>Time object is an object we often use, whether it is to do time output, time judgment and other operations are inseparable from this object. In addition to the time objects in javascript, There are many time objects in vbscript, and they are very useful. The following is also explained in accordance with our PROCESS.<br><br>It is a built-in object-not a property of other objects, allowing the user to perform various processes that use the date and Time.<br>Methods: the methods of getting time, setting time and converting time are divided into<br><br>Get the time method:<br>GetDate () to view the Date object and return the dates<br>GetDay () return day of the week<br>GetHours () Returns the number of hours<br>Getminutes () Returns the number of minutes<br>GetMonth () returns the month value<br>Getseconds () Returns the number of seconds<br>GetTime () returns the full time<br>GetYear () return year<br> <br><br>To set the time method:<br>SetDate () Date Object changed<br>sethours () Change the number of hours<br>Setminutes () Change the number of minutes<br>Setmonth () Change Month<br>Setseconds () Change the number of seconds<br>SetTime () Change the full time<br>Setyear () Change Year<br><br>Conversion Time Method:<br>toGMTString () turns the date Object's day (a numeric Value) into a GMT-time string, returning a value similar to the following: weds,15 June l997 14:02:02 GMT (exact format depends on the operating system running on the Computer)<br>toLocaleString () turns the date object's dates (a numeric value) into a string, using the specific date format used on the computer on which it is configured<br>UTC () uses date UTC (year, month, day, time, minute, Second) to return the date as a number of milliseconds since January 1, 1970 00:00:00 (where hours, minutes, seconds are optional)<br>A few points to note:<br><br>1, get the date and year and set the date and year time, the very strange problem is that the month can not be set (strange comparison):<br><script language= "javascript" ><br>d = new Date ();<br>Alert (d.tolocalestring ());<br>D.setdate (25);<br>Alert (d.tolocalestring ());<br>D.setyear (2000);<br>Alert (d.tolocalestring ());<br></script><br><br>2, when the year is best to use the getFullYear () method to do<br><br>3, because of the month, JS is starting from 0, so need to operate on the month to add 1<br><br><br><br>Here are a few of the classic and often used examples of time, I hope we will Improve. Thank you for your continued attention to this post ...<br><br>1. Convert 2005-8-5 to 2005-08-05 format<br><script language= "javascript" ><br>var strdate = ' 2005-8-5 ';<br>Window.alert (strdate.replace (/\b (\w) \b/g, ' 0$1 '));<br></script><br><br>2. Number of days to be separated<br><script type= "text/javascript" ><br><!--<br>Alert ("interval days:" + (new date (' 2005/8/15 ')-new date (' 2003/9/18 '))/1000/60/60/24+ "day")<br>-<br></script><br><br>3. Get the time interval<br><script><br>var d1=new Date ("2004/09/16 20:08:00");<br>var d2=new Date ("2004/09/16 10:18:03");<br>var d3=d1-d2;<br>var H=math.floor (d3/3600000);<br>var M=math.floor ((d3-h*3600000)/60000);<br>var s= (d3-h*3600000-m*60000)/1000;<br>Alert ("difference" +h+ "hour" +m+ "minute" +s+ "seconds");<br></script><br><br>4, Get Today's Date<br><script language= "javascript" ><br>d = new Date ();<br>Alert (d.getfullyear () + "year" + (d.getmonth () +1) + "month" +d.getdate () + "day");<br></script><br><br>6. Digital date to Chinese characters<br>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service