In my table I have a field that usses the DATETIME type (for sorting). What function do I use to put data into this field? I have tried time() and date() and niether have worked, so I was woundering how am I suppose to get data into the field.

    i usually use timestamp field for the my db, so i'm not an expert
    but when your are using a datetime field in mysql, when you insert the time, it has to match the exactly to the db.

    for example.
    datetime(6) // field type in mysqldb
    you have to put you data in this style:
    YYMMDD

    so when you a value you have to do something like this: (in php)
    date("ymd")

    if the way you try to insert the date and it doesn't match exactly to the format of the datetime field in mysql you will get a bunch of zeros.

    references:
    http://www.mysql.com/doc/en/DATETIME.html
    http://www.php.net/manual/en/function.date.php

    i hope i make myself clear.

      Thanks, that should do the trick. I was told by somone that MySQL autoformatted it for me. Thanks for clarifing it.

        Write a Reply...