Home > Web Front-end > JS Tutorial > js operation time (year-month-day hour-minute-second day of the week)_javascript skills

js operation time (year-month-day hour-minute-second day of the week)_javascript skills

WBOY
Release: 2016-05-16 18:24:46
Original
1216 people have browsed it

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 ); //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 the current milliseconds (0-999)
myDate.toLocaleDateString(); //Get the current date
var mytime=myDate.toLocaleTimeString(); / /Get the current time
myDate.toLocaleString( ); //Get the date and time


Typical application
//This will display the latest time on the page every one minute, the display format is "Sunday, June 20, 2010 12:17:14";
js





The error has been corrected here, thank you sohighthesky for your help
Related labels:
js
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template