|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
||||
|
||||
|
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.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > converting time into DB |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|