Page 1 of 1

Setting date

Posted: Wed Feb 22, 2006 10:27 am
by Wardy7
I want to set up a date bit in my mysql databse in phpmyadmin.
I want it to display in this format 03 February 2005

What do I need to set the type too? I have tried to set it to "date" and it just sets "0000-00-00" as the default :(

I must be doing something very simple wrong :oops:

Cheers
Wardy

Posted: Wed Feb 22, 2006 10:53 am
by Benjamin
I might be wrong but I am pretty sure that if you want a date stored in the database a certain way you will probably just have to use a varchar. The problem with that though is that you will not be use MySQL's built in date searching capabilities. You would be better converting it to the MySQL format for storage and then convert it back when you need to display it.

Posted: Wed Feb 22, 2006 10:58 am
by feyd
There are two recommended ways to store a date in a database. The first is to use their native DATE type, while the second stores the unix timestamp. With MySQL and the DATE type you can use DATE_FORMAT() to.. format the date. :) If you store the unix timestamp, PHP can format the date using... date(). :)