-6

I would like to create a timestamp by a variable of hour.

for example: current timestamp is:

2015-09-29 14:00:00

my variable is : $hour = 2

new timestamp that I want:

2015-09-29 16:00:00
S.M_Emamian
  • 17,005
  • 37
  • 135
  • 254

1 Answers1

2

Just use strtotime function of php.

for example:

$twoHoursAgo = Date("Y-m-d H:i:s", strtotime("-2 hours"));

for more refer below link Get the timestamp of exactly one week ago in PHP?

Community
  • 1
  • 1
Ankur Tiwari
  • 2,762
  • 2
  • 23
  • 40