Page 1 of 1

date format question

Posted: Wed Nov 15, 2006 4:08 pm
by Obadiah
ok...if i use the date format for a field in my database it stores as (YYYY-MM-DD) right? ok, now say if while filling out the form someone puts in December 30, 1973 or 12-30-1973 or simply 19731230(same day without dashes) will i get a db error?

Posted: Wed Nov 15, 2006 4:12 pm
by feyd
try it.

Posted: Wed Nov 15, 2006 4:56 pm
by RobertGonzalez
feyd wrote:try it.
Quite possibly the best advice a developer can give another developer. What is the worst that could happen?

lol, now that you know the answer to your question

Posted: Wed Nov 15, 2006 10:39 pm
by zeek
lol, now that you know the answer to your question...

If the date isn't properly formatted, it will not be stored. You could try:

Code: Select all

$formatted_date = date('Y-m-d', strtotime($raw_date) );
But the proper way to handle this issue is to simply force the formatting in the form itself. Instead of just giving a text field for the date, give a seperate dropdown for day, month, and year. Then just piece them together in your code.


PS. Hey feyd, you like my proper formatting? Uhu