jarv Posted April 13, 2011 Share Posted April 13, 2011 At the moment I have: $month_end_date[$surgeryinvoicescount]=$i[0]; = 2011-04-13 I would like $month_end_date[$surgeryinvoicescount]=$i[0]; = 13/04/2011 I have tried the following but didn't work?!: $month_end_date = date('d/m/Y',strtotime($month_end_date)); $month_end_date[$surgeryinvoicescount]=$i[0]; Link to comment https://forums.phpfreaks.com/topic/233592-display-a-time-differently/ Share on other sites More sharing options...
monkeytooth Posted April 13, 2011 Share Posted April 13, 2011 You are heading along the right path.. strtotime() requires a format like 0000-00-00 00:00:00 try $month_end_date = date('d/m/Y',strtotime($month_end_date." 00:00:00")); Link to comment https://forums.phpfreaks.com/topic/233592-display-a-time-differently/#findComment-1201049 Share on other sites More sharing options...
dcro2 Posted April 13, 2011 Share Posted April 13, 2011 You are heading along the right path.. strtotime() requires a format like 0000-00-00 00:00:00 Actually, it'll parse almost any form of date/time.. from the man page: strtotime — Parse about any English textual datetime description into a Unix timestamp Which variable actually contains the date? Is it $month_end_date[$surgeryinvoicescount], or is it $i[0]? Because for $month_end_date to be the string containing the date would make no sense, since it's an array, or you treat it like one at least. Link to comment https://forums.phpfreaks.com/topic/233592-display-a-time-differently/#findComment-1201052 Share on other sites More sharing options...
jarv Posted April 13, 2011 Author Share Posted April 13, 2011 here is what I have so far and it still doesn't work: <? $surgeryinvoicescount=0; $qry="SELECT month_end_date,xls_name,surgery_or_branch,surgery_or_branch_id,Doctor FROM invoices_to_surgerys_files WHERE month_end_date BETWEEN '$from' AND '$to' ORDER BY Doctor ASC"; $cur=mysql_query($qry); while($i=mysql_fetch_row($cur)) { $month_end_date[$surgeryinvoicescount]=$i[0]; $month_end_date[$surgeryinvoicescount] = date('d/m/Y',strtotime($month_end_date[$surgeryinvoicescount]." 00:00:00")); $xls_name[$surgeryinvoicescount]=$i[1]; $surgery_or_branch[$surgeryinvoicescount]=$i[2]; $surgery_or_branch_id[$surgeryinvoicescount]=$i[3]; $Doctor[$surgeryinvoicescount]=$i[4]; $surgeryinvoicescount++; } ?> Link to comment https://forums.phpfreaks.com/topic/233592-display-a-time-differently/#findComment-1201060 Share on other sites More sharing options...
dcro2 Posted April 13, 2011 Share Posted April 13, 2011 Try setting this error_reporting(E_ALL); ini_set('display_errors', 1); on top to see if you get any missed errors. Also, do an echo $i[0] just to make sure you're getting what you expect. Link to comment https://forums.phpfreaks.com/topic/233592-display-a-time-differently/#findComment-1201082 Share on other sites More sharing options...
Pikachu2000 Posted April 13, 2011 Share Posted April 13, 2011 Change your query string to: $qry = "SELECT DATE_FORMAT(month_end_date, '%d/%m/%Y') ,xls_name,surgery_or_branch,surgery_or_branch_id,Doctor FROM invoices_to_surgerys_files WHERE month_end_date BETWEEN '$from' AND '$to' ORDER BY Doctor ASC"; Link to comment https://forums.phpfreaks.com/topic/233592-display-a-time-differently/#findComment-1201105 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.