SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Hybrid View

  1. #1
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi guys,
    I need a method that calculates the beginning/ending Unix time of today. This is the algorithm I used but it seems to have some problems (not syntax error, it just seems to be wrong at some cases, I haven't figured it out why!)

    $begin = mktime (0,0,0,date("m",time()),date("d",time ()),date("Y",time()));
    $end = $begin + 86400;

    And one similar method for identifying the begin/end unix time within the last 7 days from current time (today)

    $end = mktime (0,0,0,date("m",time()),date("d",time())+1,date("Y",time()));
    $begin = $end - 7*86400;

    So could anybody help me here
    Any help, suggestions for better algorithm are needed
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So how often is it off, and by how much, I just changed one thing but it seems to be consistent every time I run it.

    $begin = mktime (0,0,0,date("m"),date("d"),date("Y"));
    $end = $begin + 86400;
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually I discovered the problem of inconsistency at another place in my script. However, thanks for the help!
    Btw, do you think that using Unix epoch is the best way when manipulating time values?
    And furthermore, does the problem of year 2038 come from this?
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can slap me now, but was the issue with 2038? And I can pronounce your first name, too bad we don't have speech capability in real time. (haha)
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I remember somewhere, not 100% sure!
    2038 translates into epoch value is overloaded for its capacity. I don't know if epoch is longint or what!?

    add: congratulate how about my last name?

    [Edited by 123finder.com on 11-01-2000 at 12:56 PM]
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  6. #6
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah I just tried:
    $begin = mktime (0,0,0,date("m"),date("d"),date("Y") + 38);
    And I get a -1 returned
    but
    $begin = mktime (0,0,0,date("m"),date("d"),date("Y") + 37);
    returns a valid timestamp
    Weird. I guess I will worry about then if I am still alive.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  7. #7
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    LOL @Freddy!
    I believe they will fix it soon! Not in such a short period like 2K.
    About 38 years to come. If there are no unexpectation situation , I'm still alive then!
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy


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
  •