SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    Jul 2004
    Location
    USA
    Posts
    594
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Subtracting TIMESTAMP's

    Hello,

    I know it can be done but im not sure how it would be done.

    I want to take a "RIGHT NOW" timestamp and compare it to an OLDER timestamp , and subtract them so that it shows the difference bewtween the two. Like Today, at 4:47 PM (AS NOW) and Yesturday, at 12:20 PM (AS OLDER) would output 1 day 4 hours and 27 mins ago. But if it didnt get to a day yet, it would display 0 day.

    How can this be done?
    BKerr

  2. #2
    SitePoint Addict fesh's Avatar
    Join Date
    Jan 2005
    Location
    Jackson, New Jersey
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://us3.php.net/time

    the user contributed notes have some people talking about calculating time. look in there.
    Fesh
    imagine what it's going to be like

  3. #3
    SitePoint Evangelist dmsuperman's Avatar
    Join Date
    Feb 2005
    Location
    A box
    Posts
    516
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Take the date and convert it to a timestamp, then do time()-$yesterday and you have the number of seconds. Divide by 60 for minutes, 60 again for hours, so on.
    <(^.^<) \(^.^\) (^.^) (/^.^)/ (>^.^)>
    Core 2 Duo E8400 clocked @ 3.375GHz, 2x2GB 800MHz DDR2 RAM
    5x SATA drives totalling 2.5TB, 7900GS KO, 6600GT


Bookmarks

Posting Permissions

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