0

I have a variable $datetime and when I print it I get: 2015-04-20 20:00:00. Which as far as I can see is in the format: Y-m-d H:i:s.

I'm trying to add 5 hours to this time so I'm using:

echo date("Y-m-d H:i:s", strtotime('+5 hours', $datetime));

Which is outputting: 1970-01-01 04:33:35 and I can't see why?

Rizier123
  • 58,877
  • 16
  • 101
  • 156
The Druid
  • 15
  • 5

1 Answers1

1

The second argument for strtotime() needs to be a valid timestamp, you in your example:

strtotime('+5 hours', $datetime)

should be:

strtotime('+5 hours', strtotime($datetime))
jeroen
  • 91,079
  • 21
  • 114
  • 132