Home  >  Article  >  Web Front-end  >  JavaScript uses regular expressions to remove -_javascript tips from dates

JavaScript uses regular expressions to remove -_javascript tips from dates

WBOY
WBOYOriginal
2016-05-16 16:45:161248browse

1. Description

It often happens that the date format of the page is: YYYY-MM-DD, while the date format in the database is: YYYYMMDD. The two need to be converted before they can be transferred to Java background query data.

Usually, there are two methods for this conversion. The first is to intercept the date string and then concatenate it; the second is to use regular expressions to remove "-"

In comparison, the second method is fast and less error-prone.

2. Implement the source code

Copy the code The code is as follows:

< %@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>





JavaScript removes the "-" from the date

< ;meta http-equiv="pragma" content="no-cache">













3. Implementation results

(1) During initialization
JavaScript uses regular expressions to remove -_javascript tips from dates
(2) After clicking "OK"
JavaScript uses regular expressions to remove -_javascript tips from dates
Statement:
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