Setting date

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Wardy7
Forum Commoner
Posts: 38
Joined: Wed Aug 24, 2005 4:45 am
Location: UK

Setting date

Post 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
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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(). :)
Post Reply