Entering a date into mysql

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Markw
    New Member
    • Aug 2007
    • 8

    Entering a date into mysql

    Ok this is probably going to be so obvious but I've got to ask because I can not find it any other place.

    I'm creating (still, this has been going on for some time now) a web based scuba dive log database and of course I'd like to enter the date that the dive took place.

    I understand that mysql stores the date information in the YYYY-MM-DD and if I use lets say phpmyadmin to enter the data for the dive and of course use the above format to enter the date everything is great.

    But when I start getting the web side of things going I don't want to have to enter it in that format but rather the 'usual way' of MM-DD-YYYY

    How do I accomplish this ? This might be better posted in the PHP forum but thought I'd start here first. PHP/MySQL along with CSS and xhtml are the languages I'll be using ( as I'm sure you might have guessed I'm not a programmer!! LOL)

    Thank you for your help
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    You can use PHP's strtotime and date functions to convert just about any know English date-time format into an acceptable DateTime and TimeStamp format.
    Like, for example:
    [code=php]
    $original = "June 12th 2008, 8:53:24 PM";
    echo date("Y-m-d H:i:s", strtotime($orig inal));
    # Outputs: 2008-05-15 20:53:24
    [/code]

    Comment

    • Markw
      New Member
      • Aug 2007
      • 8

      #3
      Atli,

      Thank you for the quick response. I figured it would be something easy, just didn't know were to start looking.

      Again Thank you

      Mark

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        Glad I could help :)

        Comment

        Working...