#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2007
    Posts
    98
    Rep Power
    9

    Another Date Question


    PHP 5 and MySQL 5

    In query:
    PHP Code:
    DATE_FORMAT(submitted'%m/%d/%y') AS date 
    In page:
    PHP Code:
    $date stripslashes($row['date']);
    $originaldate $date
    $ageindays number_format(floor((date("U")-strtotime($originaldate))/86400),0);
    $torenew 180 $ageindays;
    echo 
    "Renew in $torenew days."
    This worked fine prior to PHP 5 but now it doesn't. Not sure how I should adjust this to get it working. Any help appreciated.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,230
    Rep Power
    593
    "Not sure how to adjust this to get it working" either because I have no idea what " but now it doesn't" means.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2007
    Posts
    98
    Rep Power
    9
    Sorry, I forgot to mention what I was trying to accomplish. It's a resume program. The date a person enters their resume is logged in the database under the "submitted" row.

    When they login to their resume panel I want to let them to see how many days they have left before their resume will become inactive (6 months total active time from original submit date) and will have to be renewed. The script I posted above worked fine before my hosting company installed PHP 5 and MySQL 5, so I'm assuming that something in this:
    $ageindays = number_format(floor((date("U")-strtotime($originaldate))/86400),0);
    is no longer valid, but I don't know what.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,230
    Rep Power
    593
    So what is the error message? I'm trying to help but you really need to understand that clairvoyance not my strong suit.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  8. #5
  9. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,690
    Rep Power
    6351
    You don't need stripslashes, and there's no reason to use date_format to format a date to a m/d/Y only to pass it to strtotime to format it to a unix timestamp, do math on it, then translate it back into a number of days. You could do all this math right in the query using NOW() and UNIX_TIMESTAMP()
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2007
    Posts
    98
    Rep Power
    9
    I used
    DATEDIFF(NOW(),submitted) AS datediff
    Then it was simply a matter of subtracting the datediff number from 180 (6 months).

IMN logo majestic logo threadwatch logo seochat tools logo