Edit Default Value, timestamp

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
kumarrana
Forum Commoner
Posts: 26
Joined: Sat Sep 01, 2007 12:55 pm

Edit Default Value, timestamp

Post by kumarrana »

My timestamp returns date in this format 20080823235029. I would like in CURRENT_TIMESTAMP format. I noticed that my Default value is NULL. I already have bunch of post related to that date. Can somebody give me a command to change my Default value to CURRENT_TIMESTAMP with out changing any other table values.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Edit Default Value, timestamp

Post by onion2k »

Use mysql's DATE_FORMAT() function.. eg

Code: Select all

SELECT DATE_FORMAT(`table`.`timestamp_column`, "%Y-%m-%d %H:%i:%s") AS timestamp_formatted FROM `table`
Post Reply