Convert dd/mm/yyyy to yyyy/mm/dd for mysql

Discussion in 'PHP' started by frobak, Feb 7, 2012.

  1. #1
    Hi

    I need to change a uk date dd/mm/yyyy to mysql format yyyy/mm/dd

    I have a user form where they enter the date in dd/mm/yyyy string format, i want to take that string, and convert it to mysql format yyyy/mm/dd

    Possible?

    Ive searched for ages and havent found a solution that works.

    Is there an easy solution to this? surely there must be

    Cheers
     
    frobak, Feb 7, 2012 IP
  2. Joshua F

    Joshua F Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Date-Time format
    $date = "2012-02-07 19:02:41";
    echo date('Y/m/d', strtotime($date));
    PHP:
    Format for if you use time();
    $date = "1328662961";
    echo date('Y/m/d', $date);
    PHP:
    Hope this helped.
     
    Joshua F, Feb 7, 2012 IP
  3. ezprint2008

    ezprint2008 Well-Known Member

    Messages:
    611
    Likes Received:
    15
    Best Answers:
    2
    Trophy Points:
    140
    Digital Goods:
    1
    #3
    if it's going to be uploaded to SQL database , the database will DATESTAMP or TIMESTAMP it for you as soon as the record is made.
    or have two separate entry fields for the date they enter and the SQL field for it (the one that gets auto-created) Is it for a D/O/B ? or just for the record and date it was created?
     
    ezprint2008, Feb 7, 2012 IP