SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2009
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    hello any body help a dought in timestamp

    hello friends i have stored a time stamp in the database like in the format of 2009/08/04 : 17:07:21 and i am echoing another time like 2009-08-04 13:59:37
    in the program can any body know how to find out the difference between this two if u know pls express through the codes pls its urgent...

  2. #2
    SitePoint Enthusiast premiumscripts's Avatar
    Join Date
    Aug 2009
    Location
    PremiumScripts.com
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $difference_in_seconds strtotime($first) - strtotime($second); 

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2009
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hello friend thanks for the reply but how can i convert it into the hours pls give a solution if u know

  4. #4
    SitePoint Addict
    Join Date
    Apr 2009
    Posts
    248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Divide by 360?

  5. #5
    SitePoint Zealot
    Join Date
    Jul 2009
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hello friend after dividing i am getting like this 347049.993611 without dividing i am getting
    1249379977 can u tell why see i am using the full format like $start=2009/08/04 : 17:07:21
    and $end=2009-08-04 13:59:37 so tell me i am not getting the answer in a good format why? pls help me if u know

  6. #6
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,328
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by kuttus011 View Post
    pls its urgent...
    not for us it isn't

    would you please tell us the datatype of the column in the table into which you have saved the timestamp
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  7. #7
    SitePoint Zealot
    Join Date
    Jul 2009
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    timestamp...is the database type

  8. #8
    SitePoint Zealot
    Join Date
    Jul 2009
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    see i need to use this for fixing a time limit for my activation account so what i am doing but i am not getting a proper difference

  9. #9
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,328
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    where is the other timestamp coming from, the one you want to compare?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  10. #10
    SitePoint Enthusiast premiumscripts's Avatar
    Join Date
    Aug 2009
    Location
    PremiumScripts.com
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your input time is wrong it states "2009/08/04 : 17:07:21" but needs to be "2009/08/04 17:07:21" (without the : in the middle)

    Where is this date coming from?

    Also, you may want to wrap that calculation in abs() so that it doesn't matter which is the biggest date.

  11. #11
    SitePoint Zealot
    Join Date
    Jul 2009
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that i am echoing throw this $end=date("Y/m/d : H:i:s", time() + $time_a);

    this the format where i need to know the the time difference between the 2 where $start =date("Y/m/d : H:i:s", time() + $time_a); also but it will be storing to the data base then calling it and substrating with current value do u know how to do the subtraction of this where i need to get in the hour format

  12. #12
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You'd be better off getting the difference from within the query - IIRC, MySQL is much more efficient with date calculations than PHP.

    Off Topic:

    Not to come across as rude, but we've told you on almost every thread you've used it - "dought" is spelt DOUBT
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  13. #13
    SitePoint Wizard cranial-bore's Avatar
    Join Date
    Jan 2002
    Location
    Australia
    Posts
    2,634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For some reason I find seeing "dought" quite grading when I scan the PHP forum. Please start spelling it doubt as mentioned.

  14. #14
    SitePoint Zealot
    Join Date
    Jul 2009
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok doubt frnd solve the issue pls upto now i didnt get a proper answer to go forward....any body pls...


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
  •