Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2009
    Posts
    23

    Unanswered: Time stamp and time reference

    Hello

    I wanted to create in my web page a script that calculates how many hours/days/months ago something was uploaded to the database.

    e.g.

    I uploaded an ad to my site today at 08:00
    now lets say its 10:00, so i want to have a text saying
    "added 2 hrs ago"
    lets say 3 days passed
    "added 3 days ago"
    and so on....

    I tried something but couldnt get it to work.

    any suggestions ?

    Danny

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    so what did you try
    have a look at the MySQL date/time functions in da manuel
    MySQL :: MySQL 5.1 Reference Manual :: 11.6 Date and Time Functions
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jul 2009
    Posts
    23
    Hello there,

    well thats the problem i didnt realy understand that...

    what i did was....MANUALLY added a "date" column

    then with php, set a variable for today

    then subtracting ... stuppid i know!

    well any help would be appriciated

    Danny

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    select timediff(now(),mydatecolumn) as ElapsedTime from MyTable

    then use column ElapsedTime

    ..of course you could do the same calculation in your front end, forget the sordid details in PHP
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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