YYYYMMDD timestamp, how to correctly compare the time?

I have set two bits
one is start and the other is end
format is datepicker
of jquery, so it will be 2018-01-01 format
but now I want to make a comparison

I am using the concept of an e-commerce coupon
, so I need to enter the discount code
so check whether the starting time and ending time of the discount code coincides with today
if today"s time is lower than the start time, it is not available, which means that the discount code expires
suppose that today"s time is higher than the start time and lower than the end time. Then I can use
but the time I send it to the database will be a string (2018-01-01)
so that if I want to do the above comparison
, should I stamp it into time, or is it the best way to put a string date?
I thought that if I switch to a timestamp, how can I match it?
if it is the completion date, assuming that today is 2018-07-25, but the expiration date is 2018-07-26, it can still be used, so how can I compare it up and down? It is not a number, so it is more than less than

.

recharge:
I found that even if the "end time" didn"t arrive, he was still upset.

  "SELECT * FROM `discount`
      WHERE
        `code` = "{$cart_code}"
      AND
        `end` <= "".time()."" "

strongly recommends timestamps, because storage where timestamps are numeric types is faster than strings, and numeric comparisons are easier than strings
you can use strtotime to convert string time types to timestamps and compare their sizes
if the current time is less than the start time or the current time is greater than the end time. Then the coupon is not available
if the current time is between the start time and the end time, it is available


convert to timestamp

sql:select * from xx where start >= time and end <= time;

Direct size comparison is OK. String size comparison is the ASCII code of comparison characters. You can use this format completely;
"2028-01-02" > "2018-01-02"
true
"2018-01-02" > "2018-02-02"
false
"2018-01-02" > "2018-01-03"
false
"2018-01-04" > "2018-01-01-02"

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e48c67-44ce1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e48c67-44ce1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?