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
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.

Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.