Welcome to WebmasterWorld Guest from 54.211.86.24

Forum Moderators: open

mysql timestamp

timestamp

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



Hi,

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
Default = 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 Sep 8, 2010 (gmt 0)

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



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]
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month