phpknight Posted August 7, 2007 Share Posted August 7, 2007 I am going crazy trying to figure this one out. It probably has a simple answer, but I couldn't find much on a search of the forum. I am trying to insert a time into a TIME field in a mySQL table. I cannot use TIMESTAMP for this. So, I use php like this: $myTime=time(); But when this gets inserted in the database, it is either 838:59:59 or 000:00:00. What PHP function do you have to call to send the correct format to mySQL. I cannot use the mySQL CURTIME() because the things have to be done with the value before the query. Quote Link to comment https://forums.phpfreaks.com/topic/63670-solved-time-in-php-vs-mysql/ Share on other sites More sharing options...
cooldude832 Posted August 7, 2007 Share Posted August 7, 2007 I think you need to use the "u" flag on the mktime to get a unix timestamp format time Quote Link to comment https://forums.phpfreaks.com/topic/63670-solved-time-in-php-vs-mysql/#findComment-317311 Share on other sites More sharing options...
phpknight Posted August 7, 2007 Author Share Posted August 7, 2007 I am not sure what you mean. Can you write that out in PHP, and I'll test it? thanks! Quote Link to comment https://forums.phpfreaks.com/topic/63670-solved-time-in-php-vs-mysql/#findComment-317318 Share on other sites More sharing options...
phpknight Posted August 8, 2007 Author Share Posted August 8, 2007 I ended up just changing the database field to an int instead of time. It now accepts the correct value. However, if anybody figures out the original question, that would be great. Quote Link to comment https://forums.phpfreaks.com/topic/63670-solved-time-in-php-vs-mysql/#findComment-318233 Share on other sites More sharing options...
chronister Posted August 8, 2007 Share Posted August 8, 2007 I ran into the same problems a while back. I ended up doing what your doing and just make the field type an INT and using it that way. I prefer using unix timestamps over the mysql format anyway. I think their easier to deal with anyway. Nate Quote Link to comment https://forums.phpfreaks.com/topic/63670-solved-time-in-php-vs-mysql/#findComment-318246 Share on other sites More sharing options...
phpknight Posted August 8, 2007 Author Share Posted August 8, 2007 I see. I guess I'll just mark this one as solved for now. Quote Link to comment https://forums.phpfreaks.com/topic/63670-solved-time-in-php-vs-mysql/#findComment-318259 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.