1. Current system locale format (toLocaleDateString and toLocaleTimeString)
Example: (new Date()).toLocaleDateString() + " " + (new Date()).toLocaleTimeString()
Result: January 29, 2008 16:13:11
2. Ordinary strings (toDateString and toTimeString)
Example: (new Date()).toDateString() + " " + (new Date()).toTimeString()
Result: Tue Jan 29 2008 16:13:11 UTC+0800
3. Greenwich Mean Time (toGMTString)
Example: (new Date()).toGMTString()
Result: Tue, 29 Jan 2008 08:13:11 UTC
4.Universal Standard Time (toUTCString)
Example: (new Date()).toUTCString()
Result: Tue, 29 Jan 2008 08:13:11 UTC
5.Date object string (toString)
Example: (new Date()).toString()
Result: Tue Jan 29 16:13:11 UTC+0800 2008
Date object constructor
Date object has multiple constructors.
new Date()
new Date(milliseconds)
new Date(datestring)
new Date(year, month)
new Date(year, month, day)
new Date(year, month, day, hours)
new Date(year, month, day, hours, minutes)
new Date(year, month, day, hours, minutes, seconds)
new Date(year, month, day, hours, minutes, seconds, microseconds)
Date object construction Function parameter description
milliseconds - the number of milliseconds from the start time defined internally in JavaScript on January 1, 1970
datestring - the date and time represented by a string. This string can be converted using Date.parse()
year - a four-digit year, if the value is 0-99, add 1900 to it
month - 0 (representing January) - 11 (representing ten month between February)
day - date between 1-31
hours - number of hours between 0 (representing midnight) - 23
minutes - number of minutes between 0-59
seconds - number between 0-59 Number of seconds between
microseconds - Number of milliseconds between 0-999
Date object return value
Without any arguments, the current date will be returned
If the argument is a number, treat the number as a millisecond value and convert to a date
If The parameter is a string, treat the string as a string representation of the date, converted to a date
It can also be precisely defined using six constructors, and returns the time
Example
var d1 = new Date();
document.write( d1.toString());
var d2 = new Date("2009-08-08 12:12:12);
document.write(d2.toString());
var d3 = new Date(2009, 8, 8);
document.write(d3.toString());
Date is a built-in object of JavaScript and must be created using new.
Date object is expressed internally in JavaScript as the date since January 1, 1970. The number of milliseconds (timestamp) at midnight (GMT time). Here we also call the internal representation of Date a timestamp. You can use getTime() to convert the Date object into a Date timestamp. The method setTime() can convert it. The timestamp of Date is converted to the standard form of Date. The
Date function uses the syntax
date.methodname(parameter1,parameter2,...);
Date.methodname();
date represents an instance of a date object, Date represents a date object, and the date. method name calls a member function of the object
Date. The method name calls a static function of the object
Example
var d=new Date();
var d2=Date.UTC();
JavaScript_Date function is classified by function
Date acquisition class function
Date() function--Constructor of Date object
getDate() function- - Returns the number of days in the month in the date object (1-31)
getDay() function--Returns the number of days in the week in the date object(0-6)
getFullYear() function--Returns four digits in the date object Count the year
getHours() function--returns the number of hours (0-23) in the date object
getMilliseconds() function--returns the number of milliseconds (0-999) in the date object
getMinutes() function--returns the date object The number of minutes in the date object (0-59)
getMonth() function--returns the number of months in the date object(0-11)
getSeconds() function--returns the number of seconds in the date object(0-59)
getTime( ) Function -- Returns the timestamp representation of the date object (in milliseconds)
getTimezoneOffset() Function -- Returns the time difference between local time and the current date represented in UTC, in minutes
getUTCDate() Function -- Returns the date object The day of the month (1-31) expressed in Universal Coordinated Time (UTC)
getUTCDay() function-- Returns the day of the week (0-6) expressed in Universal Coordinated Time (UTC) in the date object
getUTCFullYear( ) Function--Returns the four-digit year in the date object expressed in Universal Coordinated Time (UTC)
getUTCHours() Function--Returns the number of hours (0-23) expressed in Universal Coordinated Time (UTC) in the date object
getUTCMilliseconds( ) Function -- Returns the number of milliseconds (0-999) expressed in Universal Coordinated Time (UTC) in the date object
getUTCMinutes() Function -- Returns the number of minutes (0-59) expressed in Universal Coordinated Time (UTC) in the date object )
getUTCMonth() function--returns the number of months (0-11) expressed in Universal Coordinated Time (UTC) in the date object
getUTCSeconds() function--returns the number of seconds expressed in Universal Coordinated Time (UTC) in the date object (0-59)
getYear() function--returns the year of the date object (real year minus 1900)
Date.UTC() function--returns the date object from midnight on January 1, 1970 Universal Coordinated Time (UTC) The number of milliseconds (timestamp) between
Date setting class function
setDate() function--sets the day of the month in the date object, and returns the number of milliseconds (timestamp) between the date object and midnight on January 1, 1970
setFullYear() function -- sets the year, month and day in the date object, and returns the number of milliseconds (timestamp) between the date object and midnight on January 1, 1970
setHours() function -- sets the date object Hours, minutes, seconds and milliseconds, and returns the number of milliseconds (timestamp) between the date object and midnight on January 1, 1970
setMilliseconds() function--Sets the number of milliseconds in the date object and returns the number of milliseconds in the date object since 1970 The number of milliseconds (timestamp) between midnight on January 1st
setMinutes() function--Sets the minutes, seconds, and milliseconds of the date object, and returns the number of milliseconds (time Stamp)
setMonth() function--Set the month and day in the date object, and return the number of milliseconds (timestamp) between the date object and midnight on January 1, 1970
setSeconds() function--Set the month in the date object day, and returns the number of milliseconds (timestamp) between the date object and midnight on January 1, 1970
setTime() function -- sets the date object using the number of milliseconds, and returns the number of milliseconds (timestamp) between the date object and midnight on January 1, 1970 The number of milliseconds (timestamp) between
setUTCDate() function -- sets the day of the month in the date object expressed in Universal Coordinated Time (UTC), and returns the number of milliseconds between the date object and midnight on January 1, 1970 (Timestamp)
setUTCFulYear() function -- Sets the year, month and day in the date object expressed in Universal Coordinated Time (UTC), and returns the number of milliseconds between the date object and midnight on January 1, 1970 (timestamp )
setUTCHours() function --- Sets the hours, minutes, seconds and milliseconds in the date object expressed in Universal Coordinated Time (UTC), and returns the number of milliseconds (timestamp) between the date object and midnight on January 1, 1970 )
setUTCMilliseconds() function--Set the number of milliseconds in the date object expressed in Universal Coordinated Time (UTC), and return the number of milliseconds (timestamp) between the date object and midnight on January 1, 1970
setUTCMinutes() function --Set the minutes and seconds expressed in Coordinated Universal Time (UTC) in the date object, and return the number of milliseconds (timestamp) between the date object and midnight on January 1, 1970
setUTCMonth() function -- Set the date object The month and day expressed in Universal Coordinated Time (UTC), and returns the number of milliseconds (timestamp) between the date object and midnight on January 1, 1970
setUTCSeconds() function -- Sets the date object in Universal Standard Time (UTC) represents seconds, milliseconds, and returns the number of milliseconds (timestamp) between the date object and midnight on January 1, 1970
setYear() function--set the year of the date object (real year minus 1900)
Date printing function
toDateString() function -- returns the string representation of the date part of the date object
toGMTString() function -- returns the string representation of the Greenwich Mean Time (GMT) of the date object
toLocaleDateString function -- returns the date The localized string of the date part of the object
toLocaleTimeString function--returns the localized string of the time part of the date object
toTimeString() function--returns the string of the time part of the date object
toUTCString function--returns the localized string of the date object String representation of Universal Coordinated Time (UTC)
Date parsing function
Date.parse() function--parse a date string and return the number of milliseconds (timestamp) between the date and midnight on January 1, 1970
JavaScript_Date function is classified according to letters
Date() function--Date Object's constructor
getDate() function -- returns the number of days in the month (1-31) in the date object
getDay() function -- returns the number of days in the week (0-6) in the date object
getFullYear() Function -- Returns the four-digit year in the date object
getHours() function -- Returns the number of hours (0-23) in the date object
getMilliseconds() Function -- Returns the number of milliseconds (0-999) in the date object
getMinutes() function -- returns the number of minutes (0-59) in the date object
getMonth() function -- returns the number of months (0-11) in the date object
getSeconds() function -- returns the number of minutes in the date object Number of seconds (0-59)
getTime() function--returns the timestamp representation of the date object (in milliseconds)
getTimezoneOffset() function--returns the time difference between local time and the current date expressed in UTC, in minutes
getUTCDate() function--returns the day of the month (1-31) in the date object expressed in Universal Coordinated Time (UTC)
getUTCDay() function--returns the mid-week expressed in UTC in the date object day (0-6)
getUTCFulYear() function--returns the four-digit year in the date object expressed in Universal Coordinated Time (UTC)
getUTCHours() function--returns the four-digit year expressed in UTC in the date object Hours (0-23)
getUTCMilliseconds() function--returns the number of milliseconds (0-999) expressed in UTC in the date object
getUTCMinutes() function--returns the number of milliseconds in the date object expressed in UTC The number of minutes (0-59) expressed in UTC)
getUTCMonth() function--returns the number of months (0-11) expressed in UTC in the date object
getUTCSeconds() function--returns the number of months in the date object expressed in UTC The number of seconds (0-59) expressed in Universal Coordinated Time (UTC)
getYear() function--returns the year of the date object (real year minus 1900)
Date.parse() function--parses a date string, And returns the number of milliseconds (timestamp) between the date and midnight on January 1, 1970
setDate() function--sets the day of the month in the date object, and returns the number of milliseconds between the date object and midnight on January 1, 1970 The number of milliseconds (timestamp)
setFullYear() function -- sets the year, month and day in the date object, and returns the number of milliseconds (timestamp) between the date object and midnight on January 1, 1970
setHours() Function -- Set the hour, minute, second and millisecond of the date object, and return the number of milliseconds (timestamp) between the date object and midnight on January 1, 1970
setMilliseconds() Function -- Set the number of milliseconds of the date object, And return the number of milliseconds (timestamp) between the date object and midnight on January 1, 1970
setMinutes() function--set the minutes, seconds, milliseconds of the date object, and return the date object between midnight on January 1, 1970 The number of milliseconds (timestamp) between
setMonth() function - Set the month and day in the date object, and return the number of milliseconds (timestamp) between the date object and midnight on January 1, 1970
setSeconds() function -- Set the day of the month in the date object, and return the number of milliseconds (timestamp) between the date object and midnight on January 1, 1970
setTime() function -- Set the date object using the number of milliseconds, and return the distance between the date object and The number of milliseconds (timestamp) between midnight on January 1, 1970
setUTCDate() function -- sets the day of the month in the date object expressed in Universal Coordinated Time (UTC), and returns the date object since January 1, 1970 The number of milliseconds between midnight and midnight (timestamp)
setUTCFulYear() function--Set the year, month and day in the date object expressed in Universal Coordinated Time (UTC), and return the date object since midnight on January 1, 1970 The number of milliseconds (timestamp) between
setUTCHours() function --- Sets the hours, minutes, seconds and milliseconds in the date object expressed in Universal Coordinated Time (UTC), and returns the date object since midnight on January 1, 1970 The number of milliseconds (timestamp) between
setUTCMilliseconds() function--Sets the number of milliseconds in the date object expressed in Universal Coordinated Time (UTC), and returns the number of milliseconds (time) between the date object and midnight on January 1, 1970 Stamp)
setUTCMinutes() function--Set the minutes and seconds expressed in Universal Coordinated Time (UTC) in the date object, and return the number of milliseconds (timestamp) between the date object and midnight on January 1, 1970
setUTCMonth( ) Function -- Sets the month and day expressed in Universal Coordinated Time (UTC) in the date object, and returns the number of milliseconds (timestamp) between the date object and midnight on January 1, 1970
setUTCSeconds() Function -- Setting Seconds and milliseconds expressed in Coordinated Universal Time (UTC) in the date object, and returns the number of milliseconds (timestamp) between the date object and midnight on January 1, 1970
setYear() function--Set the year of the date object ( The real year minus 1900)
toDateString() function -- Returns the string representation of the date part of the date object
toGMTString() function -- Returns the string representation of the Greenwich Mean Time (GMT) of the date object
toLocaleDateString function -- Returns the localized string of the date part of the date object
toLocaleTimeString function -- returns the localized string of the time part of the date object
toTimeString() function -- returns the string of the time part of the date object
toUTCString function -- returns the date The string representation of the object's Universal Coordinated Time (UTC)
Date.UTC() function -- returns the number of milliseconds (timestamp) between the date object and midnight on January 1, 1970 Universal Coordinated Time (UTC)

去掉重复并排序的方法:1、使用“Array.from(new Set(arr))”或者“[…new Set(arr)]”语句,去掉数组中的重复元素,返回去重后的新数组;2、利用sort()对去重数组进行排序,语法“去重数组.sort()”。

本篇文章给大家带来了关于JavaScript的相关知识,其中主要介绍了关于Symbol类型、隐藏属性及全局注册表的相关问题,包括了Symbol类型的描述、Symbol不会隐式转字符串等问题,下面一起来看一下,希望对大家有帮助。

怎么制作文字轮播与图片轮播?大家第一想到的是不是利用js,其实利用纯CSS也能实现文字轮播与图片轮播,下面来看看实现方法,希望对大家有所帮助!

本篇文章给大家带来了关于JavaScript的相关知识,其中主要介绍了关于对象的构造函数和new操作符,构造函数是所有对象的成员方法中,最早被调用的那个,下面一起来看一下吧,希望对大家有帮助。

本篇文章给大家带来了关于JavaScript的相关知识,其中主要介绍了关于面向对象的相关问题,包括了属性描述符、数据描述符、存取描述符等等内容,下面一起来看一下,希望对大家有帮助。

方法:1、利用“点击元素对象.unbind("click");”方法,该方法可以移除被选元素的事件处理程序;2、利用“点击元素对象.off("click");”方法,该方法可以移除通过on()方法添加的事件处理程序。

本篇文章给大家带来了关于JavaScript的相关知识,其中主要介绍了关于BOM操作的相关问题,包括了window对象的常见事件、JavaScript执行机制等等相关内容,下面一起来看一下,希望对大家有帮助。

foreach不是es6的方法。foreach是es3中一个遍历数组的方法,可以调用数组的每个元素,并将元素传给回调函数进行处理,语法“array.forEach(function(当前元素,索引,数组){...})”;该方法不处理空数组。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download
The most popular open source editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Dreamweaver CS6
Visual web development tools
