homepage Welcome to WebmasterWorld Guest from 54.163.139.36
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

    
mysql timestamp
timestamp
Orangutang



 
Msg#: 4197197 posted 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

 

rocknbil

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



 
Msg#: 4197197 posted 5:04 pm on Sep 8, 2010 (gmt 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]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved