I want to add 3 minutes to a date/time variable I have, but I'm not sure how to do this. I made the variable from a string like this: (which is in the RFC 2822 date format btw)
$date = 2011-10-18T19:56:00+0200
I converted that string into date using this command:
$time = date_format(DateTime::createFromFormat("Y-m-d\TH:i:sO", $date), "G:i")
Now, I'd like to add 3 minutes to that variable, but I I'm not sure how. I've used the following command in my script before, but that applies to the current date/time, so I'm not sure how to use that for my time variable:
$currenttime = date('G:i', strtotime('+2 hours'));
So, how can I add three minutes to the $time variable?
echo $idate="2013-09-25 09:29:44";
$effectiveDate = strtotime("+40 minutes", strtotime($idate));
echo date("Y-m-d h:i:s",$effectiveDate);
Since you're using the DateTime object already, stick with it:
$time = DateTime::createFromFormat("Y-m-d\TH:i:sO", $date);
$three_minutes = $time->add(new DateInterval('P2H'));
^^--two (2) hours (H)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With