How to compare the two date sizes in a database table one table in the database has two dates, one is start, the other is end, and how to compare the sizes of the two, in addition, if the end date is before the start date, a message will be prompted, and the cursor will be placed in the date box and re-input !! Please answer! ------ Solution ------------------ generally, the & lt; or & gt; number can be used directly to compare the date and datetime types of time to compare the two date sizes in the database table.
In my database, there are two dates in a table, one is start and the other is end. how can I compare the sizes of the two, and the end date will prompt information before the start date, place the cursor in the date box and try again !! Please answer!
------ Solution --------------------
Generally, you can use the <or> number to compare the time of the date and datetime types.
------ Solution --------------------
The owner's description is incorrect.
The frontend user enters two dates. if start> end is detected by js, the prompt message is displayed immediately. if the user spoofs the form request to submit start> end, the php end should also detect start <= end again when processing the form. In addition, if you want to perform better interaction, you still need to submit the form via ajax. if you do not need to update the form, php will verify the start and end. if not, an invalid ajax prompt will be returned, otherwise, insert the database and return the ajax success prompt.
------ Solution --------------------
Discussion
In my database, there are two dates in a table, one is start and the other is end. how can I compare the sizes of the two, and the end date will prompt information before the start date, place the cursor in the date box and try again !! Please answer!
------ Solution --------------------
Discussion
Reference in a format similar to 2004-10-10:
Reference:
In my database, there are two dates in a table, one is start and the other is end. how can I compare the sizes of the two, and the end date will prompt information before the start date, place the cursor in the date box and try again !! Please answer!
What type of date is your date?
If it is a string, a conversion is required.
If it is a timestamp, you can directly compare
Finally, move the cursor ......
------ Solution --------------------
It cannot be converted into a timestamp. Haha
SELECT UNIX_TIMESTAMP ('2017-10-04 22:23:00 ');
875996580