Get the App
SLTechnology News&Howtos  ›  Development  › 

How JavaScript uses the dateStrForma function

Shulou Source: shulou.com Published: 2022-06-01 02:38:16 09月22日 Update

This article mainly shows you "JavaScript how to use dateStrForma function", the content is easy to understand, clear, hope to help you solve doubts, the following let Xiaobian lead you to study and learn "JavaScript how to use dateStrForma function" this article.

DateStrForma: converts a specified string from one time format to another. The format of From should correspond to the location of str

Function dateStrForma (str, from, to) {/ / '20190626'' YYYYMMDD' 'YYYY' str + = 'let Y =''if (Y = from.indexOf ('YYYY')) {Y = str.substr (Y, 4) to = to.replace (/ YYYY | yyyy/g,Y)} else if (~ (Y = from.indexOf (' YY') {Y = str.substr (Y) 2) to = to.replace (/ YY | yy/g,Y)} let KJI ['I 'from.indexOf (slots) k = ~ I? Str.substr (I, 2):''to = to.replace (slots, k)}) return to} / / dateStrForma ('20190626,' YYYYMMDD', 'YYYY MM month DD date') = > June 26, 2019 / / dateStrForma ('121220190626 June,'-YYYYMMDD', 'YYYY MM month DD') = > June 26, 2019 / / dateStrForma ('0June 26, 2019', 'YYYY MMmonth DD') 'YYYYMMDD') = > 20190626Universe / regular can also be used to implement / /' 06.26,2019. Replace (/ (\ d {4}) year (\ d {2}) month (\ d {2}) day /,'$1murf / dateStrForma function 3') = > 2019-06-26 is all the content of the article "how to use dateStrForma functions in JavaScript". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Function content article format learning help location character string time understandable more organized regular knowledge editing industry information information channel channel Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Microsoft Linux OPPO Reno Redmi