General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 4th, 2003, 12:07 PM
ozwold ozwold is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: London UK
Posts: 4 ozwold User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
converting time into DB

Hi all,

I've got a question for yers. I've got this newsfeed and the way the time is formatted is like this:

11:18:13

Question, I've setup a time field in the DB and assigned it timestamp type field, so when I insert the time into DB it enters this as 000000000000.

How do I get it to insert the time in this format 11:18:13?? or perhaps conver it in a way so that I can display it as 11:18:13.

Is there a such way? Perhaps I then need to use the time function to output back, yeah??

Many thanks

Oz.

Reply With Quote
  #2  
Old September 4th, 2003, 12:48 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
I recommend changing your timestamp field to an int(11) field and inserting the output from PHP's time() function into that field. When you want to pull the time back out, you can use a combination of mysql's FROM_UNIXTIME() and DATE_FORMAT() functions to get the time you want. You could also make your field a datetime, insert NOW() or a 'XXXX-XX-XX XX:XX:XX' formatted date into it, then using DATE_FORMAT() on that value to display the time however you see fit.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > converting time into DB


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT