php - Recalculating dates stored as type varchar -


I have a table that contains the expiration dates for the software module. They are stored in varchar (32) form The database stores the dates of one day prior to the end of the dates and the dates of one day before expiry. When a license is terminated, the message is notified by the message stack when the customer goes to the site administrator.

What I want, should be able to edit the date of expiry, so that a customer license issue can be added for additional months or years, it is necessary to update other dates relative to the new expiry Or they should not get warnings.

Then in the field 'edate' the date is stored as 25-10-2015, 'Wdate' contains 25-09-2014 and 'fwdate' is 24-10-2015

How do you take the date stored in the DB and make it usable with the code as seen below, which originally counts the date.

$ todays_date = strtotime ("now"); $ Delta_Eleven = Stromathemate ("+ 11 months"); $ Delta_364 = strontium ("+ 1 year -1 day"); $ Delta_year = strotomat ("+ 1 year"); $ Idate = Date ("D-M-Y", $ todays_date); $ Wdate = Date ("D-M-Y", $ Delta_Elevan); $ Fwdate = Date ("D-M-Y", $ delta_364); $ Edate = Date ("D-M-Y", $ delta_yure); The interpretation of the second parameter can be found on the database side you can use.

  SELECT STR_TO_DATE (your_date_column, '% d-% m-% Y') from your_ table;  

You can use

  SELECT STR_TO_DATE (your_date_column, '% d-% m-% Y') to add or subtract something + Your table for 11 months from the interval; Select  

or

  STR_TO_DATE (your_date_column, '% d-% m-% Y') + Interval 1 year - 1 day from your_table;  

If you add a column with the appropriate datatype (date, date time, or timestamp), then it will be best, with the new str_to_date () function Update the columns and then drop the old Merchandise column that contains your dates. This makes the task a lot easier and if necessary you can use indexed on the column.


Comments