July 1, 201313 yr Good Morning, I've outputted some data from a MSSQL database, the data within the database reads '01/07/2013 11:11:16' and when I access this via a PHP script and echo it ... It displays as 'Jul 01 2013 11:11:16PM'. I need the format to be in : '2013-07-11 11:11:16'. Please can someone help me write the code to make the str change to the format needed. Kind Regards, Shaun Swales Http://www.twitter.co.uk/ShaunSwales
July 1, 201313 yr mysql has a date_format function which converts the date directly, I'm not sure if mssql has a similar function. PHP has a bunch of date/time functions - you can look them up in the php manual. I think you'll need to convert the date to a unix timestamp and then convert it to your required format. Assuming $date is the date you've retrieved, you could do something like $formatted = strftime('%Y-%m-%d %H:%M:%S', strtotime($date));
Create an account or sign in to comment