Home > Web Front-end > JS Tutorial > body text

js code to display the current system time_time and date

WBOY
Release: 2016-05-16 17:39:42
Original
1604 people have browsed it

js gets the current system time

Copy code The code is as follows:

var myDate = new Date();
myDate .getYear(); //Get the current year (2 digits)
myDate.getFullYear(); //Get the complete year (4 digits, 1970-????)
myDate.getMonth(); / / Get the current month (0-11, 0 represents January)
myDate.getDate(); // Get the current day (1-31)
myDate.getDay(); // Get the current week X (0 -6,0 represents Sunday)
myDate.getTime(); // Get the current time (the number of milliseconds since 1970.1.1)
myDate.getHours(); // Get the current hours (0-23 )
myDate.getMinutes(); //Get the current minutes (0-59)
myDate.getSeconds(); //Get the current seconds (0-59)
myDate.getMilliseconds(); //Get the current milliseconds (0-999)
myDate.toLocaleDateString(); //Get the current date
var mytime=myDate.toLocaleTimeString(); //Get the current time
myDate.toLocaleString() ; //Get date and time

js code to display the current system time


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!