In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the knowledge of "how javascript converts timestamps into days". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.
JS converts the year, month, day, minute and second string into a timestamp
Var time = Date.parse (new Date ("2020-08-31 16:00")
A timestamp representing 2020-08-31 16:00 will be output:
1598860800000
Time stamp converted to number of days
The cut-off time minus the current time to calculate the number of days from the end of the distance
Var d = new Date (); var rangeDateNum = (d.getTime ()-time) / (1000 / 3600 / 24)
Ex.: convert 1598860800000 into days
Var time = Date.parse (new Date ("2020-08-31 16:00"); var d = new Date (); var rangeDateNum = (d.getTime ()-time) / (1000 / 3600 / 24); console.log (rangeDateNum)
Output result:
371.9680493634259
Extended knowledge: timestamp to date
/ / parseInt () string to digital / / new Date () into the timestamp without the default current time this.tabledata [I] .createTime = this.formatDate (new Date (parseInt (this.tableData[ I] .createTime)) / / timestamp conversion date format formatDate (now) {var year = now.getFullYear (); / / gets a 4-digit year var month = now.getMonth () + 1 / / get the month in the date, where 0 is January, 11 is December var date = now.getDate (); / / return the number of days in the date month (1 to 31) var hour = now.getHours (); / / the number of hours in the return date (0 to 23) var minute = now.getMinutes (); / / the number of minutes in the return date (0 to 59) var second = now.getSeconds () / / return the number of seconds in a date (0 to 59) return year + "-" + month + "-" + date + "" + hour + ":" + minute + ":" + second;} "how javascript converts timestamps into days". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.