1 Reply Latest reply on May 6, 2009 8:16 AM by asdaf1234

    Date Manipulation in PHP, MySQL, ADDT

    James_PT Level 1

      I have a datetime stored in MySQL  I retrieve it from the ADDT update transaction via the following statement:

       

      $last_date = KT_escapeForSql($tNG->getColumnValue("last_kpi_gen_date"),$tNG->getColumnType("last_kpi_g en_date"));

       

      Now I want to add 1 day, 7 days, or a month to the date.  I try using mktime but it appears it wants it in a different date order (h,m,s, y-m-d),  I've tried the strtotime function and the date function to reformat $last_date, but it doesn't seem to work.

       

      Is there an easy way to add days to a date varible extracted from a MySQL database using ADDT getColumnValue?

        • 1. Re: Date Manipulation in PHP, MySQL, ADDT
          asdaf1234 Level 1

          Hi, I am trying to do it this way:

           

          You can make VIEW for MySQL with current time +8 hours:

           

          create view DATETIME as
          SELECT DATE_FORMAT(DATE_ADD(now(), INTERVAL 8 HOUR), '%Y-%m-%d %H:%i:%s') as DT_add8hour;

           

          Or with +8 days:

           

          create view DATETIME as
          SELECT DATE_FORMAT(DATE_ADD(now(), INTERVAL 8 DAY), '%Y-%m-%d %H:%i:%s') as DT_add8day;

           

          This stores allways CURRENT time plus interval value. So You can use this to update other table colums to time you want. Works perfectly with DW+ADDT+PHP+MySQL  

           

          Here are more Date and Time Functions

           

          Hope this helps you!

           

          Message was edited by: asdaf1234