dbk Posted June 15, 2010 Share Posted June 15, 2010 Hi I can't seem to get the dateformat the way I want! From mysql the dateformat is yyyy-mm-dd, but I would like to display it dd-mm-yyyy in my page! How do I do this? And is it possible to display it like dd.mm.yyyy? This is a part of the code: $project_db = "SELECT * FROM $db_$db_tbl_project WHERE project_id = '" . $_SESSION['project_number'] . "' "; $project_result = mysql_query($project_db) or die("Invalid query: " . mysql_error()); $project_row = mysql_fetch_array($project_result); $project_start_date = $project_row['project_start_date']; Link to comment https://forums.phpfreaks.com/topic/204885-help-with-date-format-query-from-mysql/ Share on other sites More sharing options...
kenrbnsn Posted June 15, 2010 Share Posted June 15, 2010 I'm sure someone will show you how to format the date directly in MySQL, so here's how to do it in PHP... use a combination of the strtotime and date functions: <?php $project_start_date = $project_row['project_start_date']; echo date('d-m-Y',strtotime($project_start_date)); // // or // echo date('d.m.Y',strtotime($project_start_date)); ?> Or you can to it without strtotime and date <?php list($yr,$mon,$day) = explode('-',$project_start_date); echo "$day-$mon-$yr"; // // or // echo "$day.$mon.$yr"; ?> Ken Link to comment https://forums.phpfreaks.com/topic/204885-help-with-date-format-query-from-mysql/#findComment-1072585 Share on other sites More sharing options...
dbk Posted June 15, 2010 Author Share Posted June 15, 2010 Beautiful kenrbnsn!! My hero Thanks! Link to comment https://forums.phpfreaks.com/topic/204885-help-with-date-format-query-from-mysql/#findComment-1072592 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.