Home > Article > Web Front-end > JavaScript uses regular expressions to remove -_javascript tips from dates
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