Newbie needs date/time help please

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
roguephp
Forum Newbie
Posts: 5
Joined: Tue Dec 31, 2002 7:57 am
Location: Mount Laurel, New Jersey USA

Newbie needs date/time help please

Post by roguephp »

Hi all,

Newish to mySQL and php - I am developing a small table of class schedules. I am not sure what the best way to store (and what format) the start and end time for each class. I want to display something like this:

12:00pm - 1:30pm

Any assistance would be great. Thanks.

- Charles
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

If you store the times in a TIME or TIMESTAMP type column in MySQL then you can easily use one of MySQLs Date & Time Functions such as DATE_FORMAT() to convert the time to how you'd like to display it. Doing it this way means that if you change the way you'd like to display the data you don't have to change the data only the SQL statement drawing the info out.

Mac
Post Reply