Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.3k views
in Technique[技术] by (71.8m points)

js中怎么把像"10月2日 23:23:34开售"之类的字符串直接转成时间戳的函数?

如题js中有把像
"10月2日 12:12:12开售"

"2020年12月5日 12:12:23结束"
转成时间戳的函数,
其中年可能带可能不带,时间后面有汉字,而且汉字字数不确定。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

试试这个

parseInt(new Date("10月2日 23:23:34开售".replace(/[u4e00-u9fa5]/g,' ')).getTime()/1000)

image


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...