SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    Pragmatic Programmer halfasleeps's Avatar
    Join Date
    Feb 2006
    Location
    Altoona, PA. USA
    Posts
    1,945
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how can I tell when it is 2am EST tomorrow?

    I need to put something on a page and then make it disappear tomorrow morning at 2am EST...How can I do this? I think I need to compare something with the date() function but not sure exactly how to do it...and since I can't really test to see if it works until its too late...I thought maybe someone could help me out?

    Thanks!!
    Altoona Design
    Freelance Flex developer for hire.
    ActionScript Programmer with 8 Years Experience.

  2. #2
    derrrp
    Join Date
    Aug 2006
    Location
    earth
    Posts
    923
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    You can use mktime() to generate a timestamp for whatever date and time you want.

    Then use that to compare with
    PHP Code:
    strtotime('now'); 
    .
    No, I REALLY dislike having to use Joomla.

  3. #3
    Pragmatic Programmer halfasleeps's Avatar
    Join Date
    Feb 2006
    Location
    Altoona, PA. USA
    Posts
    1,945
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is what I am thinking:
    PHP Code:
    $year date('Y');
    $month date('m');
    $day date('d');
    $hour date('G');
    if(
    $year == 2009 && $month && $day 28 && $hour 2)
    {
        
    $show_promo true;

    Altoona Design
    Freelance Flex developer for hire.
    ActionScript Programmer with 8 Years Experience.

  4. #4
    Pragmatic Programmer halfasleeps's Avatar
    Join Date
    Feb 2006
    Location
    Altoona, PA. USA
    Posts
    1,945
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by crowden View Post
    Hi,

    You can use mktime() to generate a timestamp for whatever date and time you want.

    Then use that to compare with
    PHP Code:
    strtotime('now'); 
    .
    Thanks so like this:
    PHP Code:
    if(mktime(2,0,0,1,27,2009) < strtotime('now'))
                {
                    
    $show_promo true;
                } 
    Altoona Design
    Freelance Flex developer for hire.
    ActionScript Programmer with 8 Years Experience.

  5. #5
    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)
    or, simpler:
    PHP Code:
    $show_promo = (time() < strtotime('2am 2009-02-27')); 
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  6. #6
    Pragmatic Programmer halfasleeps's Avatar
    Join Date
    Feb 2006
    Location
    Altoona, PA. USA
    Posts
    1,945
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by arkinstall View Post
    or, simpler:
    PHP Code:
    $show_promo = (time() < strtotime('2am 2009-02-27')); 
    Very elegant, thank you!
    Altoona Design
    Freelance Flex developer for hire.
    ActionScript Programmer with 8 Years Experience.


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
  •