Thread: Age of record

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

    Join Date
    Dec 2014
    Location
    Colorado, United States
    Posts
    12
    Rep Power
    0

    Age of record


    I am trying to do a report which shows the age of each record since being added. I get the most incredible results like 34533 days for a 4 day old record so I am doing something wrong obviously.

    The field for when the record was added is $created. The field for the report to show each record age is $timeopen and the row for each record looks like this:

    $row3 .= "<tr>
    <td>$created</td>
    <td>$company</td>
    <td>$contact</td>
    <td>$status</td>
    <td>$timeopen</td>
    <td><a href='delete.php?id=$id'>Del</a></td>

    The date time is in the php I am using for $created is:

    date_default_timezone_set('GMT');
    $created= date("Y-m-d H:i");

    It shows like this: 2015-04-09 10:59:21

    The $timeopen is just that I have used no formatting at all. Let me know the mistake.
    Any help is appreciated.
  2. #2
  3. Lazy Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,436
    Rep Power
    9645
    So the problem you're having is with the value of $timeopen, right? How about posting how $timeopen gets its value?

    Comments on this post

    • Catacaustic agrees : Beat me to it. :)
  4. #3
  5. Code Monkey V. 0.9
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2005
    Location
    A Land Down Under
    Posts
    2,327
    Rep Power
    2063
    How do you actually calculate the days open? I can't see that in your code anywhere.
  6. #4
  7. No Profile Picture

    Join Date
    Apr 2015
    Location
    Accra
    Posts
    4
    Rep Power
    0
    I actually didn't get your problem right but, if you want to have the age of a record you could just same the timestamp along while adding that record. To display it you can use php functions and SQL functions to display the record's age easily.

IMN logo majestic logo threadwatch logo seochat tools logo