How to subtract days from a plain Date?
Try something like this: Note that this modifies the date object and returns the time value of the updated date.
Try something like this: Note that this modifies the date object and returns the time value of the updated date.
Try to cast it as a DATE
You could use: There are plenty of constants in Calendar for everything you need. Check the Calendar class documentation.
The type is Date: It is the same as with every other object instance 🙂
Put the date in single quotes and move the parenthesis (after the ‘yes’) to the end: But you can always use dates without STR_TO_DATE() function, just use the (Y-m-d) ‘20120101’ or ‘2012-01-01’ format. Check the MySQL docs: Date and Time Literals
For more information regarding the Date object, please refer to MDN or the ECMAScript 5 specification.
Use strtotime() and date(): (See the strtotime and date documentation on the PHP site.) Note that this was a quick solution to the original question. For more extensive conversions, you should really be using the DateTime class to parse and format 🙂
The field DATE in the database has the following format: I would like to remove the time from the date and return the date like this: