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
    New Coder
    Join Date
    Mar 2004
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    date manipulation

    I have a problem with the dates and how to format them - both when inserting and querying from DB.

    Our users uses the dates in the "29-04-2004" (dd-mm-yyyy) format. The mySQL DB needs them in the "04-29-2004" (mm-dd-yyyy) (the US format).

    Is there a function in mySQL/PHP that can convert directly? OR do I need to make a string manipulation? and what do I use to convert the string f.ex "29-04-2004" into "29" and to "04". I hava a PHP manual but could not really find anything that could 'cut' strings to pieces?

    Thanks,
    Serap

  • #2
    Mega-ultimate member
    Join Date
    Jun 2002
    Location
    Winona, MN - The land of 10,000 lakes
    Posts
    1,855
    Thanks
    1
    Thanked 45 Times in 42 Posts
    Try this...
    PHP Code:
    $var "29-04-2004";//Hey, that's my Birthday! :)
    list($day$month$year) = split("-",$var); 

  • #3
    New Coder
    Join Date
    Mar 2004
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok thanks for the tip...

    Do you if is is possible to change the server date (yyyy-mm-dd) to something else in mySQL so that you dont need to make conversions each time?

  • #4
    Mega-ultimate member
    Join Date
    Jun 2002
    Location
    Winona, MN - The land of 10,000 lakes
    Posts
    1,855
    Thanks
    1
    Thanked 45 Times in 42 Posts
    Check out the mysql documentation:

    http://www.mysql.com/doc/en/Date_and...functions.html


  •  

    Posting Permissions

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