Jump to content


Photo

Changing the format of a time field?


  • Please log in to reply
1 reply to this topic

#1 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 24 January 2006 - 06:49 PM

As default, the MySQL time datatype is formatted like this: HH:MM:SS, I'm trying to default it to just HH:MM - I have tried setting the fields character length to 5, and I have tried setting the default attribute to 00:00. Neither of these two attempts appear to have worked. Is this possible, or am I looking at altering the times with PHP after I have pulled it from the database?

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 24 January 2006 - 07:27 PM

Use MySQL's TIME_FORMAT function -- TIME_FORMAT(yourField, '%H:%i').
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users