<> How to convert timestamps to time formatted strings

** Server return time is a string of numbers with Unix Starting from the first year of time , Return the corresponding time stamp
** Time stamp is seconds

* Convert timestamps to Date object ( millisecond )
* take Date Format , Convert to corresponding string
** format (data,‘yyyy-MM-dd hh:mm:ss’)

y:year year
M:Month month ( Capitalized , Make a distinction with minutes )
d:day day
h:hours hour (h,12 hour / H,24 hour )
m:minutes minute
s:seconds second

** What is regular expression for ?
** string matching
<> Matching rules
+: One or more
*:0 One or more
?:0 One or one

1. Get year
if (/(y+)/.test(fmt)) { fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').
substr(4 - RegExp.$1.length)); }
** I don't know how many others sent y, First, check the information from others y Number of
** RegExp.$1 It's a match y Replace it with the following result
** date.getFullYear() + ’ ’ Convert year numbers to strings
** substr() Number of interceptions
<> The code is as follows function formatDate(date, fmt) { // Get year if (/(y+)/.test(fmt)) { fmt =
fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
} // Get more let o = { 'M+': date.getMonth() + 1, 'd+': date.getDate(), 'h+': date.
getHours(), 'm+': date.getMinutes(), 's+': date.getSeconds() }; for (let k in o)
{ if (new RegExp(`(${k})`).test(fmt)) { let str = o[k] + ''; fmt = fmt.replace(
RegExp.$1, (RegExp.$1.length === 1) ? str : padLeftZero(str)); } } return fmt; }
; function padLeftZero(str) { return ('00' + str).substr(str.length); };
Why separate the year from others ?
Year may display two digits Two digits may also be displayed
Because if the time required to be displayed is Time, minute and second are two bits
padLeftZero Algorithm complements two bits

Technology
©2019-2020 Toolsou All rights reserved,
ElementUI In the select Of label value Spark SQL- programming Output string at specified position ( Detailed analysis )Vue Transfer parameters and receiving of page Jump Science fiction comes true !“ Trisomy ” Found out Forbes China Auto rich list : He xiaopengdi 11 Li Xiangdi 14 Li Bindi 15( Essence )2020 year 7 month 15 day Wechat applet import and include difference Note 14 : The second biggest obstacle to motivating others in R & D management pytorch of ResNet18( Yes cifar10 The accuracy of data classification is achieved 94%) Determine whether the current object is an array 4 Methods