• Welcome to the eight year blog, I'm glad to meet you at the right age!
  • Due to the theme, QQ login partners will display the default avatar in the comments. Please go to the personal center and upload the avatar again.

Convert JS timestamp to normal digital time format

Code Notes barben One year ago (September 19, 2020) 1401 views 0 comments

In the middle of the night, I found the back end of the interface Bring good people The time field passed to me is actually a timestamp format???

 JS timestamp format to digital format
Originally, I wanted the back end to change this timestamp to a value that can be seen by a man in the sun, but when I look at the time

2020-09-20 02:06:05

Excuse me, I'll do it myself!!!!

 function getdate(time) { var now = new Date(time), y = now.getFullYear(), m = now.getMonth() + 1, d = now.getDate(); return y + "-" + (m < 10 ? "0" + m : m) + "-" + (d < 10 ? "0" + d : d) + " " + now.toTimeString().substr(0, 8); } console.log(getdate(1600413432000)); //  2020-09-18 15:17:12


Eight blogs that year, we've been there all the time
If the author does not indicate the original article, please indicate the link and source of this article
Convert JS timestamp to normal digital time format- https://www.barben.cn/code/897.html
Like it( fifteen )
Post my comments
Cancel comment
expression Mapping Bold Strikethrough Center Italics

You need to bring your nickname and email with you in the year of eight!

  • Nickname (required)
  • Email address (required)
  • website