Rewriting date from MySQL

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
ab0x
Forum Newbie
Posts: 2
Joined: Mon Oct 09, 2006 4:50 pm

Rewriting date from MySQL

Post by ab0x »

Hi everyone!

When I insert data into an SQL database that needs to be time stamped I like to use the "NOW()" function built into MySQL. This inserts information that looks like "2006-11-10 16:26:20" and while I enjoy using this on the database end, it isn't too readable when I'm displaying it.

When I grab the data from the database for displaying I would like to rewrite it to, for example, something like "November 10th, 2006 at 4:26"

How would I do this?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

You might find something useful in the documentation of the date and time functions of mysql, http://dev.mysql.com/doc/refman/5.0/en/ ... tions.html
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

Why don't you look at the date() function. If you pass it a timestamp, it will format the date information in anyway you want. Your only hurdle would be changing the date format you have to a timestamp. There may be a built in MySQL function that can do this or one of the other php date / time functions.

Cheers
Post Reply