Page 1 of 1

Add days to a date

Posted: 2013-10-10 13:13
by espo
Hello to all,

I can add 9 days to a date?

How should I do, I have to work with the hooks and what code should I enter?


Thank you very much.

Re: Add days to a date

Posted: 2013-10-15 06:59
by espo
Hello,

no one can explain how to add days to a date, and what code I have to add in hooks?

example
12/10/2013 insert and in the field to obtain (+ 8 days) 20/10/2013

Thank you very much.

Re: Add days to a date

Posted: 2013-10-16 01:08
by a.gneady
Here is some generic code that you can adapt:

Code: Select all

/* before adding to date, you need to convert it to timestamp */
$date1_timestamp = strtotime($data['date1']);

/* then add 8 days (convert to seconds first) */
$date2_timestamp = $date1_timestamp + 8 * 24 * 60 * 60;

/* finally convert to date2 */
$data['date2'] = date('Y-m-d', $date2_timestamp);

Re: Add days to a date

Posted: 2013-10-16 09:31
by espo
Hello Ahmad,

thank you very much.
I'll try and let you know.

Re: Add days to a date

Posted: 2014-07-16 01:25
by kavlito
Thank you very much. This works great!