Detailed description of the applet time formatting (util. formatTime (new Date), and the applet util. js
Small Program time formatting
Although the mini-program is still in beta testing, it is not enough. Hurry up and record the learning path.
Obtain the time by using Date. now () to obtain a string of numbers. For example:
Use util. formatTime (new Date) to obtain the formatted time)
Util is a tool provided in the official demo:
Function formatTime (date) {var year = date. getFullYear () var month = date. getMonth () + 1 var day = date. getDate () var hour = date. getHours () var minute = date. getMinutes () var second = date. getSeconds () return [year, month, day]. map (formatNumber ). join ('/') + ''+ [hour, minute, second]. map (formatNumber ). join (':')}
The obtained time is as follows:
Thank you for reading this article. I hope it will help you. Thank you for your support for this site!