ridiculous Posted October 13, 2007 Share Posted October 13, 2007 You've got a MySQL DATETIME string that you pull out of the db as a variable. Why? Because you're cool. And, because this DATETIME is so hot right now. Our DATETIME looks like: 2007-10-13 03:47:05 But you want it to take off its clothes and get it to look like: 3:47:05 ================================================= What line(s) would you use on this skanky little DATETIME to get it how you want it? Its the speed that's key here, boys. We all know you can pull out and use a lame ass substring function. But we should all be above that by now. Plus you're looking for a little more wham bam thankyou ma'am in this situation. Quote Link to comment https://forums.phpfreaks.com/topic/73067-solved-fastest-way-to-format-mysql-datetime-in-php-5/ Share on other sites More sharing options...
ridiculous Posted October 13, 2007 Author Share Posted October 13, 2007 For why do I have these troubles? $t = "2007-10-13 03:47:05"; date_format($t, "Y-m-d H:i:s"); "Warning: date_format expects parameter 1 to be DateTime WTF? Quote Link to comment https://forums.phpfreaks.com/topic/73067-solved-fastest-way-to-format-mysql-datetime-in-php-5/#findComment-368467 Share on other sites More sharing options...
Barand Posted October 13, 2007 Share Posted October 13, 2007 SELECT DATE_FORMAT(datecol, '%k:%i:%s') as thetime .... Quote Link to comment https://forums.phpfreaks.com/topic/73067-solved-fastest-way-to-format-mysql-datetime-in-php-5/#findComment-368468 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.