js时间处理

后端需要数据与自己获取数据不一致时,用正则很方便

let str = 2021年09月29日;

let reg = /(\d{4})\年(\d{2})\月(\d{2})日/;
str.replace(reg, "$1-$2-$3") //可以得到2021-09-29
posted @ 2021-09-29 09:53  奇函数  阅读(26)  评论(0)    收藏  举报