actually I save date in database in varchar format.
firstly I retrieve date from databae & store it into $date.
now i want to perform addition of 5 days with $date1.
when i search on internet i got this code :
$date = date('Y-m-d', strtotime("+5 days"));
now can you tell me how I insert $date1 value to this code for get expected result.
Working with strtotime you could to something like this:
The first
strtotime($date)call converts the string into an timestamp integer, the secound call takes that integer and adds 5 days to it. Thendateformats it back into a stringOn a sidenote:
There is not really a need to save a date as a varchar since mysql (which i guess is what you are using from the tag) will also work with “DATETIME” fields for you. E.g.
SELECT DATETIMEFIELD FROM tablewill return ‘2010-01-01 00:00:00’ or a “DATE” field will return “2010-01-01”, both arestrtotimeparseable 🙂