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

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

黄舟
Release: 2017-11-04 14:01:21
Original
2409 people have browsed it

Definition and Usage

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

Syntax

Date()
Copy after login

Example

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

<script type="text/javascript">

document.write(Date())

</script>
Copy after login

Output:

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

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对象
Copy after login


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!

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