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? 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 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. 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'])); 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
Archived
This topic is now archived and is closed to further replies.