Home  >  Article  >  Web Front-end  >  JavaScript method Date() that returns the date and time of the day

JavaScript method Date() that returns the date and time of the day

黄舟
黄舟Original
2017-11-04 14:01:212399browse

Definition and Usage

The Date() method returns the date and time of the current day.

Syntax

Date()

Example

In this example, we will output today’s date and time:

<script type="text/javascript">

document.write(Date())

</script>

Output:

Sat Nov 04 2017 13:57:47 GMT+0800 (中国标准时间)

1. Introduction
1.1 Description

DateObject is an object for operating date and time. The Date object can only operate on date and time through methods.

1.2 Attributes

None; the Date object can only operate on date and time through methods.

2. Constructor
2.1 new Date(): Return the current local date and time

Parameters: None

Return value:

{Date} Returns a Date object representing the local date and time.

Example:

var dt = new Date();
console.log(dt); // => 返回一个表示本地日期和时间的Date对象


The above is the detailed content of JavaScript method Date() that returns the date and time of the day. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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