www.webdeveloper.com
Results 1 to 4 of 4

Thread: [RESOLVED] Insert Date in Table using FORM

Hybrid View

  1. #1
    Join Date
    Nov 2012
    Posts
    13

    resolved [RESOLVED] Insert Date in Table using FORM

    HI, I work with DW CS6 and MySQL...
    I have created a form to insert records in a table... I introduce a date in a textBox and when I insert the record in the database table, the field date appears this way: 0000-00-00

    I have tried to write the date in the form in diferent masks but always in the table of database was inserted 0000-00-00

    Somebody could help me?

  2. #2
    Join Date
    Jan 2006
    Location
    MN
    Posts
    440
    Dates are stored in the format yyyy-mm-dd in MySQL but can be displayed as in many ways using date_format.

    DATE_FORMAT(date,format)

    SELECT DATE_FORMAT(date, %M %e, %Y) AS mydate FROM mytable

    date would be something like 2012-12-02

    and mydate would be December 2, 2012

  3. #3
    Join Date
    Nov 2012
    Posts
    13
    Dasher, thanks for help...
    I didn't know that format must be YYYY-MM-DD
    I have tried to insert record with this type of date and it works perfectly. Thanks you very much. Now, I need to convert "spanish date"-> "31/12/1999" to "1999-12-31"... i will try to make a function.

  4. #4
    Join Date
    Oct 2010
    Location
    Ohio
    Posts
    233
    Hi sinchan,

    for converting try looking at the DateTime class or strtotime with date. An example using DateTime might look like:

    PHP Code:
    $date '31/12/1999'// or however you want to get it set
    $date DateTime::createFromFormat('m/d/Y'$date);
    $date $date->format('Y-d-m');

    echo 
    $date//see the results 
    ~Ryan
    www.rdennispallas.com <-- Personal Site, changing regularly cuz its ugly.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles