digitalgod Posted April 6, 2007 Share Posted April 6, 2007 hey guys, I'm currently storing the date and time in a table like so 20070406145935 and I would like to output it like 06/05/2007. To do that right now I'm doing this and it works perfectly CONCAT_WS( '/', SUBSTRING(tickets.timestamp, 7,2), SUBSTRING(tickets.timestamp, 5,2), SUBSTRING(tickets.timestamp, 1,4)) but I was wondering if t here was a better way of doing this though... Quote Link to comment https://forums.phpfreaks.com/topic/45899-better-way-of-using-substring/ Share on other sites More sharing options...
dough boy Posted April 6, 2007 Share Posted April 6, 2007 I believe the DATE_FORMAT function is what you are looking for. http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html DATE_FORMAT(tickets.timestamp,%m/%d/%Y) Quote Link to comment https://forums.phpfreaks.com/topic/45899-better-way-of-using-substring/#findComment-222985 Share on other sites More sharing options...
gluck Posted April 6, 2007 Share Posted April 6, 2007 I believe the DATE_FORMAT function is what you are looking for. http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html DATE_FORMAT(tickets.timestamp,%m/%d/%Y) I second this Quote Link to comment https://forums.phpfreaks.com/topic/45899-better-way-of-using-substring/#findComment-223010 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.