Add a 1-hour expiration to the current time/date

前端 未结 5 579
没有蜡笔的小新
没有蜡笔的小新 2021-01-06 02:04
//expiration
$datetoday = date(\"F j, Y, G:i\");

$expquery = mysql_query(\"SELECT a_expire FROM regform_admin WHERE status = \'Pending for payment\'\");
$row = mysq         


        
相关标签:
5条回答
  • 2021-01-06 02:37
    $one_hour_from_now = strtotime('+1 hour');
    

    So, all you need is:

    $expire = date('F j, Y, G:i', strtotime('+1 hour'));
    
    0 讨论(0)
  • 2021-01-06 02:40

    try it:

    $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 讨论(0)
  • 2021-01-06 02:48
    $expire = date("F j, Y, H:i", time()+3600); // 3600 sec in hour
    
    0 讨论(0)
  • 2021-01-06 02:50
    $expire = date("F j, Y, H:i", strtotime('+1 hour'));
    
    0 讨论(0)
  • 2021-01-06 02:58

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

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

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

    0 讨论(0)
提交回复
热议问题