Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    905
    Thanks
    23
    Thanked 5 Times in 5 Posts

    mysql to us date formatting

    Hi there,

    Trying to take mysql date format and output it as us standard YYYY-DD-MM however it seems to be ignoring my date.. here is my code...

    PHP Code:
    <?
    $oldDate
    ="2005-12-01";
    $newDate date("m-d-Y"$oldDate);
    echo 
    $newDate;
    ?>
    // This returns :
    1970-01-01
    Any ideas?
    Cheers,
    Sir P

  • #2
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    This is a php question not a mysql question but
    PHP Code:
    <?
    $oldDate
    ="2005-12-01";
    $newDate date("m-d-Y"strtotime($oldDate));
    echo 
    $newDate;
    ?>

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Posts
    905
    Thanks
    23
    Thanked 5 Times in 5 Posts
    Doh sorry :/

    Thanks for the code

  • #4
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,634
    Thanks
    4
    Thanked 148 Times in 139 Posts
    You can do it directly in mysql instead of having to do any of the work in php, just use DATE_FORMAT.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •