Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Dec 2006
    Posts
    23
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Cool How to trim or sub a date variable?

    Hello!

    Im trying to figure out how to show tickets on my site thats older then 14 days, how do i do that? here are my codes

    Code:
    /* old_tickets */
    $now_old = 'NOW()';
    $sql_old = "SELECT * FROM `hesk_tickets` WHERE `dt`<= $now_old AND ";
    $sql_old .= Categories();
    $sql_old .= " AND `status`>=1 ";
    $result_old = dbQuery($sql_old)
    $all_old = dbNumRows($result_old);
    
    At the moment it shows all tickets, if i replace this for an example :
    
    $sql_old = "SELECT * FROM `hesk_tickets` WHERE `dt`<= '2007-01-23 11:48:03' AND ";
    I can see that it only shows some tickets, older ones..that it should be.

    But how do i trim the $now_old variable so that it automatic will be put 14 days older than just NOW() = todays date etc.

    what im after is something like :
    Code:
    $now_old = 'NOW()'-14days
    :P

  • #2
    New Coder
    Join Date
    Jul 2006
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Use something like this

    PHP Code:
    $now_old date('Y-m-d h:i:s'mktime(0,0,0,date("m")-2,date("d")-22,date("Y"))); 
    Good luck!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •