Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
How to insert current time in MySQL?
Old 01-07-2008, 01:13 AM How to insert current time in MySQL?
babyboy808's Avatar
Average Talker

Posts: 16
Trades: 0
Hi,

What is the correct format for inserting the current time into MySQL?

Basically I want a 24 hour time to be stored in the db and when outputted through php I get something like: 13:46.

thanks in advance,
Keith
__________________
Keith

Please login or register to view this content. Registration is FREE
babyboy808 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-07-2008, 07:40 AM Re: How to insert current time in MySQL?
Extreme Talker

Posts: 238
Location: United States
Trades: 0
Use TIME as your field type, and use the MySQL NOW() function when inserting.

It will store the time with seconds included, such as 13:46:23, so if you don't want the seconds when you retrieve it from the database, you'll have cut off the seconds and the second colon with PHP's substr() or something.

There are also other ways to store times in MySQL, such as DATETIME, TIMESTAMP or an INT which contains the Unix timestamp. The TIME field uses the least amount of storage space out of all the options, but remember that it doesn't store any information about the date.
frost is offline
Reply With Quote
View Public Profile
 
Old 01-08-2008, 11:49 PM Re: How to insert current time in MySQL?
babyboy808's Avatar
Average Talker

Posts: 16
Trades: 0
Thanks alot frost for your in depth response, I appreciate you taking the time to help

Keith
__________________
Keith

Please login or register to view this content. Registration is FREE
babyboy808 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How to insert current time in MySQL?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.43640 seconds with 12 queries