0

I've got a date:

$date = date_create_from_format(<!--some code-->)

I want to add a day to it like this:

$date->add(+1 day)->format('F jS, Y')

Here, "->add(+1 day)" is pseudocode for the desired function/operation to add a day to $date. Not sure how to implement as I don't know what kind of object $date is or what procedure to use; i.e. "->(some operation)" or "somefunction($date)"

  • *I don't know what kind of object $date is* Why not check the manual: http://php.net/manual/en/function.date-create-from-format.php ?! Also while you are in the manual maybe check the right side to see all methods this object has. – Rizier123 Apr 06 '16 at 19:05
  • So, it's a DateTime object? A___n___d___, I use it like this: `$amount= new DateInterval('P1D');$date->add($amount);` – stackoverfloweth Apr 06 '16 at 19:09
  • Yes, you can also check it with `echo get_class($date);`. And yes you add 1 day like this, but you can also just use `modify()` and write `->modify("+ 1 day")` – Rizier123 Apr 06 '16 at 19:11
  • I think I'm going to try `->modify()`... – stackoverfloweth Apr 06 '16 at 19:13
  • @Rizier123, Should this question be deleted? – stackoverfloweth Apr 06 '16 at 19:21
  • Well there are already some Q&A's answering your question how to add 1 day to a date: http://stackoverflow.com/q/1394791/3933332 , but at the end it's up to you. – Rizier123 Apr 06 '16 at 19:24

1 Answers1

0

Example to add a day to now with \DateInterval :

echo (new \DateTime())->add(new \DateInterval('P1D'))->format('Y-m-d')
ceadreak
  • 1,662
  • 2
  • 18
  • 27