Problem with converting number to date

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PUNEETHH2O
    New Member
    • Aug 2013
    • 1

    Problem with converting number to date

    I am taking yyyy,mm,dd from difrent select boxes.
    while i concatinate this using following code.
    $dob=$doby.$dob m.$dobd; /it gives as yyyymmdd/
    but i want it in format yyyy-mm-dd
    i have tried this
    $dob=implode('-', array($doby, $dobm, $dobd));but it subtracts 3 numbers(ie. 2000-10-10 = 2080)
    I want it as 2000-10-10 to insert into DataBase
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    You already know how to concatenate so you just need to concatenate the dash characters.
    Code:
    $dob=$doby.'-'.$dobm.'-'.$dobd;

    Comment

    • Dormilich
      Recognized Expert Expert
      • Aug 2008
      • 8694

      #3
      i have tried this
      $dob=implode('-', array($doby, $dobm, $dobd)); but it subtracts 3 numbers (ie. 2000-10-10 = 2080)
      then you most probably did not use quotes in the query. hence SQL sees an expression and evaluates it. (btw. 2000-10-10 = 1980)

      Comment

      Working...