2 Replies Latest reply: Apr 1, 2013 5:01 PM by matthew stuart RSS

    Need to add 8 hours to a MySQL DATETIME

    matthew stuart Community Member

      I'm using PHP and I need to add 8 hours to a DATETIME column in my DB. I want to be able to create a time limit for a user to edit an entry they've entered in my DB.

       

      For example, I would like to hide a button [something like: show if datetime <= NOW()] which prevents me going update page once the deadline has expired...

       

      The code I have in my insert behaviour is this:

       

      .$_POST['fld_vLOCKDATE'] = date('Y-m-d H:i:s').

       

      and I am trying to create something like this:

       

      .$_POST['fld_vLOCKDATE'] = date('Y-m-d H:i:s' + 'INTERVAL 8 HOURS').

       

      or

       

      .$_POST['fld_vLOCKDATE'] = date('Y-m-d H:i:s +8 HOURS').

       

      but I am just getting records with 0000-00-00 00:00:00

       

      If I use the following code, then the current time is posted, not 8 hours in front:

       

      .$_POST['fld_vLOCKDATE'] = date('Y-m-d H:i:s, INTERVAL 8 HOURS').

       

      Any thoughts as to what I am doing wrong? In fact, if you've got any thoughts on another way I can attack it, then I'd welcome those suggestions too. I did think about using a timestamp and then: "saying show if TIMESTAMP <= 8 hours old" but my computer don't get plain English, and I obvoiulsy don't talk good computer!

       

      Thanks.