Page 1 of 1

date() function problems

Posted: Fri Jul 19, 2002 11:13 am
by fariquzeli

Code: Select all

<?php echo date(d-M-Y); ?>
I have that code above being echoed out in a form field. The form is then submitted to a database and displayed on the main page. I want the date to appear ast day-month-year so 7-19-02, yet whenever I display the contents of the database in the table it says 00-00-0000. Anyone know the best way to make the date go into a database and be formatted properly?

Posted: Fri Jul 19, 2002 11:58 am
by Howard547
The field type in your db table forthe date is probably set to DATE, which is 0000-00-00, change your field type to VARCHAR

Posted: Fri Jul 19, 2002 12:03 pm
by fariquzeli
get a mysql error:
Error

SQL-query :

ALTER TABLE `pancorp`.`news` ADD `date` VARCHAR NOT NULL

MySQL said:


You have an error in your SQL syntax near 'NOT NULL' at line 1
when changing it to varchar

Posted: Fri Jul 19, 2002 12:04 pm
by fariquzeli
nm, had to specify character length, thanks.