How to convert js timestamp to date format: First, you can get the timestamp through the getTime method; and then convert it into the corresponding date format through the Date toLocaleString method.
【Recommended course: JavaScript Tutorial】
js method to get the current timestamp:
Method 1:
1 2 3 4 |
|
This method will get the timestamp in milliseconds Change to 000 to display
Method 2:
1 2 3 4 5 |
|
This method is to get the timestamp of the current millisecond
As shown in the picture Show
js to convert the timestamp into a common date format
Method 1: Date toLocaleString method
1 2 3 4 5 6 |
|
Rendering:
##Method 2:
1 2 3 4 5 6 7 |
|
Rendering:
##Summary: The above is the entire content of this article, I hope it will be helpful to everyone
The above is the detailed content of How to convert js timestamp to date format. For more information, please follow other related articles on the PHP Chinese website!