date() function problems

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fariquzeli
Forum Contributor
Posts: 144
Joined: Mon Jun 24, 2002 9:16 am
Location: Chicago
Contact:

date() function problems

Post 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?
Howard547
Forum Newbie
Posts: 13
Joined: Fri Jul 19, 2002 11:58 am

Post 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
fariquzeli
Forum Contributor
Posts: 144
Joined: Mon Jun 24, 2002 9:16 am
Location: Chicago
Contact:

Post 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
fariquzeli
Forum Contributor
Posts: 144
Joined: Mon Jun 24, 2002 9:16 am
Location: Chicago
Contact:

Post by fariquzeli »

nm, had to specify character length, thanks.
Post Reply