In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, the editor will bring you about how to achieve vue3 timestamp conversion without using a filter. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.
Vue2 generally uses filters when converting timestamps. After vue3, vue3 removes filters and can no longer be used. Officially, it is recommended to use methods or evaluate attributes.
A Time.ts file is written below, which can be converted for timestamps:
Class Time {/ / format time public formatTime (time: number) {let date = new Date (time * 1000); let year = date.getFullYear (); let month = date.getMonth () + 1; let day = date.getDate (); let hour = date.getHours (); let minute = date.getMinutes (); let second = date.getSeconds () Return year + "-" + month.toString (). PadStart (2, "0") + "- + day.toString (). PadStart (2," 0 ") +" + hour.toString (). PadStart (2, "0") + ":" + minute.toString (). PadStart (2, "0") + ":" + second.toString (). PadStart (2, "0");} const time = new Time () Export default time
If you use it, just call this method in the template and pass in the corresponding timestamp.
{{time.formatTime (timestamp)}}
The effect displayed is:
2021-05-17 10:59:59
At present, it can only be converted to the above format. If you need more formats, you can add a second parameter in formatTime to indicate the formatted time format, and then convert it according to the format.
The above is the editor for you to share how to achieve vue3 timestamp conversion without using a filter. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.