将当前时间添加到DateTime

I would like to add 5 days and current time to a date, which I have in string.

$date = new DateTime('2013-11-21');
date_add($date, date_interval_create_from_date_string('5 days'));
$curtime = date('H:i:s');

How to add current time to DateTime, or is there any other better way how to do it?

Just edit your last lane - I think it is the most objective solution to your problem. The rest of your code is correct.

$curtime = $date->format('Y-m-d H:i:s');

Remember that your second lane is just an alias to:

$date->add(DateInterval::createFromDateString('5 days'));

So the full code would be:

$date = new DateTime('2013-11-21');
$date->add(DateInterval::createFromDateString('5 days'));
$curtime = $date->format('Y-m-d H:i:s');

EDIT: I've just read your question again and you ask about adding current time to this date. If you want to add time, then you need to create it from current date. It's not the perfect solution, but I'm still working on it:

$now = new DateTime(date('1970-01-01 H:i:s'));
$date->add(DateInterval::createFromDateString($now->getTimestamp() . ' seconds'));
$curtime = $date->format('Y-m-d H:i:s');
echo $curtime;

EDIT2: I've corrected it much more, look at this code:

$date = new DateTime('2013-11-21');
$date->add(DateInterval::createFromDateString('5 days'));

$now = new DateTime('now');
$today = new DateTime(date('Y-m-d'));

$time = $today->diff($now);

$date->add($time);

echo $date->format('Y-m-d H:i:s');

EDIT3: And remember about time zones:

$date = new DateTime('2013-11-21', new DateTimeZone('Europe/Warsaw'));
$date->add(DateInterval::createFromDateString('5 days'));

$now = new DateTime('now', new DateTimeZone('Europe/Warsaw'));
$today = new DateTime(date('Y-m-d'), new DateTimeZone('Europe/Warsaw'));


$time = $today->diff($now);

$date->add($time);

echo $date->format('Y-m-d H:i:s');

And fiddle: http://sandbox.onlinephpfunctions.com/code/0080d18d18dd7e2fefa7dea7d961087f14ceb3df

You can add 5 days like this:

 $nextX = time() + (5 * 24 * 60 * 60);

5 days * 24 hours * 60 mins * 60 secs

Try:

$date = '2013-11-21';
$date = strtotime($date);
$date = strtotime("+7 day", $date);
echo date('M d, Y', $date);

Try this

$hour_two = "2013-11-21";
$date = strtotime($hour_two);
$hour_two = $date  + (5 * 24 * 60 * 60);
$hour_two=date('Y-m-d',$hour_two);
$currenttime = date('H:i:s');
$h =  strtotime($currenttime);
$minute = date("i", $h);
$second = date("s", $h);
$hour = date("H", $h);
$new_time = $hour_two." ".$hour.":".$minute.":".$second;
echo $new_time."<br/>"; // here is your final date time
$timeto_string=strtotime($new_time);    // test using strtotime
echo date('Y-m-d H:i:s',$timeto_string);  // print by formating
$curtime = date('H:i:s');
$date = @date("Y-m-d H:i:s",strtotime($mydate.$curtime)) ;