Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

mysql timestamp


4:24 pm on Sep 6, 2010 (gmt 0)

Junior Member

5+ Year Member

joined:July 13, 2010
votes: 0


I've got a table called quotes and one of the columns has a field named datesent.

I set this column up as:
Field = datesent
Type = timestamp
Attributes = on update CURRENT_TIMESTAMP

When the form data is sent to the mysql db the datesent cell is populated with 2010-09-06 15:04:05 which is what I needed.

Now I'm trying to retrieve it, reformat it to 06-09-2010 15:04:05, and display it to user.

Is there anything like mysql_insert_id() which will enable me to retrieve the time stamp data rather than the last AI field or will I have to find another way wth php.

Any help or pointers would be a great help.

Many thanks
5:04 pm on Sept 8, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 28, 2004
votes: 0

select date_format('2010-09-06 15:04:05',"%m-%d-%Y %H:%i:%s") as reformatted;

-> 09-06-2010 15:04:05

12 hour clock,

select date_format('2010-09-06 15:04:05',"%m-%d-%Y %h:%i:%s %p") as reformatted;

-> 09-06-2010 03:04:05 PM

Just sub your field name for the hard coded date, like

$query = "select date_format(your_field_name,"%m-%d-%Y %h:%i:%s %p") as reformatted from table where id=$id";

Docs [dev.mysql.com]

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members