Add 1 hour output to current time / date

//expiration
$datetoday = date("F j, Y, G:i");

$expquery = mysql_query("SELECT a_expire FROM regform_admin WHERE status = 'Pending for payment'");
$row = mysql_fetch_array($expquery); 
$expirydate = $row['a_expire'];
echo "$datetoday";
echo "$expirydate";
if ($datetoday == $expirydate) {
    $expirequery = mysql_query("UPDATE regform_admin SET status = 'Expired' WHERE status = 'Pending'");
    $expirequery2 = mysql_query("UPDATE regform SET status = 'Expired' WHERE status = 'Pending'");
}
//end expiration

Hi, I have a reservation code here. My problem is that if the client makes a reservation at 23:30, and the reservation expires at 00:30 (1 hour), I made this code:

$currentdate = date("F j, Y, G:i");  
$onehour = date("G") + 1;
$expire = date("F j, Y, $onehour:i");

$onehourshould increase, but the problem is that booking 23:30 should expire at 24:30. But after increasing $ onehour, 23:30 leads to 24:40. Which my program can not read from wartime 12 am 00:00, not 24:00. Anyone have any suggestions in my problem? Thank you Sorry for lazy english, I'm tired of thinking

+5
source share
5 answers
$expire = date("F j, Y, H:i", strtotime('+1 hour'));
+10
source
$expire = date("F j, Y, H:i", time()+3600); // 3600 sec in hour
+2
source
$one_hour_from_now = strtotime('+1 hour');

, , , :

$expire = date('F j, Y, G:i', strtotime('+1 hour'));
0

:

$t = strtotime('2015-10-27 11:19:04');
$d = date('Y-m-d H:i:s', $t );
echo $d . "<br/>";
$t = $t + 3600;
$d = date('Y-m-d H:i:s', $t );
echo $d . "<br/>";
0

Why don't you just check if the current hour is 23? Something like (I'm not sure about the php syntax of the ternary operator):

$onehour = date("G) > 22 ? 0 : date("G) + 1;

Then you also want to change the current day and see if you change the year.

-1
source

All Articles