-3

I have a form that people are filling in and adding appointment times to, im then inputting the form into a sql db. Im then making a sheet and that shows the appointment slot. All that I need to to is add 1 hour to the appointment slot time. I have a variable call $time that is the appointment time I have tried the following:

<?php 
$time=strtotime("+3600"); 
$final=date("H:i",$time);
echo $final; 

but it comes back with all different times any ideas how to make this work?

Ian
  • 24,116
  • 22
  • 58
  • 96

1 Answers1

1
$time=strtotime("+1 hour"); 
$time=strtotime("+60 minutes"); 

Strtotime means: String to time, very useful method when working with dates in PHP.

Or like below answer:

$time = time() + 3600;

Note that you should avoid calculation with strings, that is: A number between quotes. (string)"3600" vs (int)3600

Lapidi
  • 116
  • 4
  • Hi cant seem to get it to work I have just tried I have 20:00 in the original time but it is returning 16:44 when i put it through the code – Scott Daniels Dec 17 '15 at 20:44
  • I suspect that the time on your server is wrong. Try this: `` This gives you the servertime which should be the current time (or +x hours for other timezones). Depending on what type of machine you are working on, you have to update this – Lapidi Dec 17 '15 at 21:34
  • If this isn't the case, try google for `ntp update [Server OS]` – Lapidi Dec 17 '15 at 21:40