从文本中提取日期 [英] Extract date from text
本文介绍了从文本中提取日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用此代码从文本中提取日期,而没有时间.有没有什么方法可以提取日期而不需要时间,反之亦然?
I'm using this code to extract date from text without time. Is there any method to extract date without time and vice versa?
$(document).on("change", "#select_date", function() {
const at = $('#select_date :selected').text()
//2016-03-26 15:22:02
const attend_date = at.substring(0,10)
});
推荐答案
您可以按空格split()
日期并选择第一部分:
You can split()
the date by space and select the first part:
$(document).on("change", "#select_date", function() {
const at = $('#select_date :selected').text()
const attend_date = at.split(' ')[0]
})
这篇关于从文本中提取日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文