Jump to content

display a time differently?!


jarv

Recommended Posts

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

:shrug:

 

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

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.

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++;
}
?>

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";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.