0

I get current time:

$today = time();
$date = date('h:i:s A', strtotime($today));

How do I add 5 hours to the current time?

Raptor
  • 53,206
  • 45
  • 230
  • 366
Avni Das
  • 3
  • 5
  • the dupe is a little dated should really be using http://php.net/manual/en/class.datetime.php –  Aug 03 '15 at 04:19

1 Answers1

1
$today = time();
date('h:i:s A', strtotime('+5 hours'), $today);

strtotime will parse any textual datetime description in English.

Kristian Vitozev
  • 5,791
  • 6
  • 36
  • 56
  • Thank you, heres what I tried and its working :) $today = date('m/d/y'); $addhours = 18000; $date2 = date('h:i:s A', strtotime($today)+$addhours); echo $date2; – Avni Das Aug 03 '15 at 04:26
  • Glad to hear! You can learn more about `strtotime` by reading the topics above marked as duplicated. You can accept the answer as well. – Kristian Vitozev Aug 03 '15 at 04:29