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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jan 2007
    Posts
    217
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Converting to Date

    Hey guys,

    I collect some data from a user registration form in the format:

    Day: 1-31 Month: 1-12 Year- 1990-2007

    I was wondering, how i can convert this into proper date format so i can store it in my database :P?

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    I'm assuming you meant that hyphen to be a colon after year:
    PHP Code:
    $string 'Day: 12 Month: 8 Year: 2007';
    $array array_filter(explode(' '$string));
    $date implode('-', array($array[5], $array[3], $array[1]));
    // $date = '2007-8-12'; 


  •  

    Posting Permissions

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