Home  >  Article  >  Web Front-end  >  JavaScript method toLocaleString() to convert a Date object into a string based on local time

JavaScript method toLocaleString() to convert a Date object into a string based on local time

黄舟
黄舟Original
2017-11-08 14:06:333585browse

Definition and Usage

toLocaleString() method can convert the Date object to String according to the local time, and return the result .

Syntax

dateObject.toLocaleString()

Return value

A string representation of the dateObject, expressed in the local time zone and formatted according to local rules.

Example

Example 1

In this example, we will convert today’s date into a string according to local time:

Output:

2017/11/8 下午2:06:15

Example 2

In this example, we will convert a specific date into a string according to local time:

Output:

1983/7/21 上午1:15:00

How Use toLocaleString() to convert today's date to a string based on local time.







Result:

2017/11/8 下午2:07:26

The above is the detailed content of JavaScript method toLocaleString() to convert a Date object into a string based on local time. 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