cleary1981 Posted July 22, 2008 Share Posted July 22, 2008 Hi Im having a problem with the date format mysql has returned. It returns dates in the format yyyy-mm-dd. I want to diplay this as dd-mm-yyyy. Has anyone got an easy method for converting this in php? Quote Link to comment https://forums.phpfreaks.com/topic/116004-solved-date-returned-from-mysql/ Share on other sites More sharing options...
kenrbnsn Posted July 22, 2008 Share Posted July 22, 2008 If you want to do this in PHP do: <?php $display_date = date('d-m-Y',strtotime($mysql_data)); ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/116004-solved-date-returned-from-mysql/#findComment-596437 Share on other sites More sharing options...
cleary1981 Posted July 22, 2008 Author Share Posted July 22, 2008 Im not quite sure how I would implement this. Heres the code I have <?php require "config.php"; $proj = $_REQUEST['proj']; $sql = "SELECT * FROM project WHERE project_name='$proj'"; $result = mysql_query($sql) or trigger_error(mysql_error()); $row = mysql_fetch_assoc($result); $return = $row['proj_id']."%". $row['project_name']."%". $row['form']."%". $row['access']."%". $row['cable_entry']."%". $row['ip_rating']."%". $row['fault_rating']."%". $row['company_name']."%". $row['proj_manager']."%". $row['deadline']; echo $return; ?> $row['deadline'] contains the date that I want to format. Quote Link to comment https://forums.phpfreaks.com/topic/116004-solved-date-returned-from-mysql/#findComment-596521 Share on other sites More sharing options...
revraz Posted July 22, 2008 Share Posted July 22, 2008 $return = $row['proj_id']."%". $row['project_name']."%". $row['form']."%". $row['access']."%". $row['cable_entry']."%". $row['ip_rating']."%". $row['fault_rating']."%". $row['company_name']."%". $row['proj_manager']."%". date('d-m-Y',strtotime($row['deadline'])); Quote Link to comment https://forums.phpfreaks.com/topic/116004-solved-date-returned-from-mysql/#findComment-596526 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.