Home > Web Front-end > JS Tutorial > body text

JavaScript利用正则表达式去除日期中的-_javascript技巧

WBOY
Release: 2016-05-16 16:45:16
Original
1211 people have browsed it

1、说明

经常会出现这样的情况,页面的日期格式是:YYYY-MM-DD,而数据库中的日期格式是:YYYYMMDD,两者之间需要转换一下,方能传到Java后台查询数据。

通常,这种转化的方法有两种,第一种,将日期字符串先截取,然后拼接;第二种,就是利用正则表达式去掉“-”

相比较而言,第二种方法快捷,不容易出错。

2、实现源码

复制代码 代码如下:







JavaScript去除日期中的“-”















3、实现结果

(1)初始化时
JavaScript利用正则表达式去除日期中的-_javascript技巧 
(2)单击“确定”后
JavaScript利用正则表达式去除日期中的-_javascript技巧
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!