JS Displays the current system time code _ time Date

Source: Internet
Author: User

JS Get current system time

Copy Code code as follows:

var mydate = new Date ();
Mydate.getyear (); Get Current year (2-bit)
Mydate.getfullyear (); Get full year (4-bit, 1970-????)
Mydate.getmonth (); Get Current month (0-11, 0 for January)
Mydate.getdate (); Get the current day (1-31)
Mydate.getday (); Get Current week x (0-6, 0 for Sunday)
Mydate.gettime (); Gets the current time (number of milliseconds since 1970.1.1)
Mydate.gethours (); Get the current number of hours (0-23)
Mydate.getminutes (); Get the current number of minutes (0-59)
Mydate.getseconds (); Get the current number of seconds (0-59)
Mydate.getmilliseconds (); Get current number of milliseconds (0-999)
Mydate.tolocaledatestring (); Get Current date
var mytime=mydate.tolocaletimestring (); Get current time
Mydate.tolocalestring (); Get Date and time

JS Displays the current system time code

<textarea id="runcode36043"><ptml xmlns= "http://www.w3.org/1999/xhtml" > <pead> <meta http-equiv= "Content-type" text /html; charset=gb2312 "/> <title> system time </title> <script language=" javascript "type=" Text/javascript "> <!--//Get the current time, the scale is 1000 minutes a second var initializationtime= (new Date ()). GetTime (); function Showlefttime () {var now=new Date (); var year=now.getyear (); var month=now.getmonth (); var day=now.getdate (); var Hours=now.gethours (); var minutes=now.getminutes (); var seconds=now.getseconds (); Document.all.show.innerhtml= "" "+year+" Year "+month+" month "+day+" Day "+hours+": "+minutes+": "+seconds+" "; One second refresh display time var timeid=settimeout (showlefttime,1000); //--> </script> </pead> <body onload= "Showlefttime ()" > <label id= "Show" > Display the location of the time </ label> </body> </ptml></textarea>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.