SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2010
    Posts
    167
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Bizarre date problem...

    This is really weird and I'm hoping there's a really simple answer...

    According to php.net, to get the current day of the week you should use

    Code PHP:
    $day = date("l");

    So this is my code:

    Code PHP:
    // Set Timezone
    date_default_timezone_set('America/New York');
     
    // What day of the week is it (Mon - Sun)
    $day = date("l");

    But it keeps saying today is "Mon"

    This isn't even a full textual representation of the day, it's just a textual representation of a day, three letters which according to php.net is achieved by using date('D') - Yet even when I use this it still says "Mon"

    Why is it doing this when today is in fact Friday in New York (Saturday where I am) --- nowhere in the world is it currently Monday!

  2. #2
    SitePoint Evangelist
    Join Date
    Oct 2005
    Location
    Michigan, USA
    Posts
    434
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    That is weird. I don't really know why that's happening. One thing, though, "New York" should have an underscore instead of a space. That shouldn't be the problem, though.
    http://www.php.net/timezones

    If you run just that code, $day is "Mon" ?
    - Robert

  3. #3
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php
    // Set Timezone
    date_default_timezone_set('America/New_York');
    // What day of the week is it (Mon - Sun)
    $day date("l");
    echo 
    $day;
    ?>
    That shows Saturday for me (since today is Saturday when making this reply).
    Ian Anderson
    www.siteguru.co.uk

  4. #4
    SitePoint Evangelist captainccs's Avatar
    Join Date
    Mar 2004
    Location
    Caracas, Venezuela
    Posts
    516
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by CBResources View Post
    Why is it doing this when today is in fact Friday in New York (Saturday where I am) --- nowhere in the world is it currently Monday!
    Could we see the full code that prints out "Mon?"
    Denny Schlesinger
    web services

  5. #5
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    71 Post(s)
    Tagged
    0 Thread(s)
    My first impulse is to say "Your system time is off."... do you get Monday for every date function?
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.


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
  •