SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Zealot waji's Avatar
    Join Date
    Dec 2004
    Location
    United Kingdom
    Posts
    137
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    adding two times

    Hello,

    How Can I add two times;

    Example1

    Time1: 2 day(s) 4hours 23minutes
    Time2: 23:20 (23hours and 20minutes) { time two doesn't have any days}


    How can we find the duration?
    Example 2

    Time 3: 30/04/2009 11:45
    Time 4: 30/04/2009 23:34

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Exactly what format are you getting the dates as, and where are they coming from?

  3. #3
    SitePoint Zealot waji's Avatar
    Join Date
    Dec 2004
    Location
    United Kingdom
    Posts
    137
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    These values are coming from another function;

    but the exact format is

    Time1: 2 days 4hours 23minutes
    Time2: 11:15

    as first we have to convert Time1 and Time2 to unix time stamp (which I don't know, I tried strtotime) but unsuccessful) and then adding them by some how,

    looking forward

  4. #4
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    .. and the other function cannot be made to return reasonable data?

    Time1: 2 days 4hours 23minutes
    Time2: 11:15

    Time1 2 days from when?
    Time2: 11:15 what, am- pm , today? tomorrow?

  5. #5
    SitePoint Zealot waji's Avatar
    Join Date
    Dec 2004
    Location
    United Kingdom
    Posts
    137
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Consider it to be entered by text fields

    Example

    Time 2:
    Code:
    <input name="time" type="text"  value="11:15"  size="10" />

  6. #6
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    You are not making yourself clear.

    Where are you getting 2days 4hours and 23minutes from?

    What format is that in?

    What do you want to do with it? Add it to something, if so what?

    It might be a lot easier if you were to post an example of what you have, and what you want to end up with.

    p.s. If you can influence the way the data is presented and you do want to use strtotime() then get the date in mm/dd/yyy order and it will work for you.


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
  •