Jump to content

Display date in report


danFL39

Recommended Posts

Hello,

 

I have read several of the posts here regarding time and date format but I am still stumped on getting the query below to display the date in my desired format.  (Ex:  19 Jul, 2010 or July 19, 2010)

 

The code below results in my date column displaying as a 10 digit number.  (Ex: 1272511591)

 

Could someone show me the exact revision necessary to my code?

 

Thanks.

 

$table=array('brands','order_products','orders','products');
$relationships=array('`orders`.`orderid` = `order_products`.`orderorderid`','`order_products`.`ordprodname` = `products`.`prodname`','`products`.`prodbrandid` = `brands`.`brandid`');
$fields=array('orders.orderid',('orders.orddate.date'),'orders.ordbilllastname','order_products.ordoriginalprice','order_products.ordprodname','brands.brandname');
$group_by=array('brands.brandname');
$sort_by=array(array('orders.orderid','0'));
$layout='AlignLeft1';
$style_name='Colorful';
$title='MPT Sales by Designer';
$file_name='GZ Sales by Designer - Jul 2010';
$records_per_page='50';

Link to comment
https://forums.phpfreaks.com/topic/208247-display-date-in-report/
Share on other sites

Where's the code creating the date?

 

Need to know what php function you use to create the date. http://w3schools.com/php/php_ref_date.asp

For example here's the tips for creating the format you use if using gmdate() http://w3schools.com/php/func_date_gmdate.asp

Thanks for your reply.  The results of my code above are displayed in a table via a php page.  None of the date/time functions in your link are being used.  I am trying to figure out what function to use and where to place it in the above code.  Below shows the current results my php code is generating.

 

 

orderid orddate ordbilllastname ordoriginalprice ordprodname

17 1254598665 Sauve 4.9500 JS 46 Birth Announcements Girl

30 1255985691 Chartier 24.9500 JS Holiday Vol-7 Pro Set

33 1256229437 Colwill 29.9500 JS 46 Hammond Guide Pro Set-V1

33 1256229437 Colwill 29.9500 JS 46 Hammond Guide Pro Set-V3

33 1256229437 Colwill 29.9500 JS 46 Hammond Guide Pro Set-V4

Use the date() function described above, and then use the link I referenced in previous post for reference.

 

But where ever it is that you are printing out the data to the screen file whatever... instead use to print out.

$MY_DATE = yourdate.... I need to see the code you are printing out the data with

echo date('j M, Y', $MY_DATE);

 

 

Thanks guys.  I guess I am too much of a noob to understand where to make the revision.  Below is the php page that generates the on screen report output.

 

?>



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title><?php  echo $title ?></title>



<link href="<?php 

if($print!= 0)

{

echo "print.css" ;

}

else

{

echo $style_name . ".css" ;

}

?>" rel="stylesheet" type="text/css" />

</head>



<body class="MainPage">

<table border="0"

<?php

//width of report

if($print != 0)

  echo "width='500'";

else

  echo "width ='100%'";

?>



align="center" cellpadding="2" cellspacing="0" class="MainTable" >

  

    <!-- ************************* Menu code **************************** !-->

    <?php 

if($print !=3 ) //not in real priting mode

{

?>

    <tr>

    <td height="27" class="menu"  colspan="<?php echo $actual_columns_count; ?>" id="menu_row">

<?php 

 include("menu.php")

 ?></td>

  	  </tr>

  	<?php 

  	}

  	?>

  <!-- *************************End Of Menu code **************************** !-->

  

  <!-- ******************** start custom header ******************** !-->

  <?php

  if(!empty($header))

  {

    ?>

  <tr>

    <td colspan="<?php echo $actual_columns_count?>"  valign="top" ><?php echo($header);?></td>

  </tr>

  <tr>

    <td colspan="<?php echo $actual_columns_count?>"  valign="top" class="Separator" ></td>

  </tr>

<?php

  }

  ?>

  <!-- ******************** end custom header ******************** !-->

  <tr>

    <td colspan="<?php echo $actual_columns_count?>"  valign="top" class="Title" ><?php  echo($title);?></td>

  </tr>

  <tr>

    <td class="Separator" colspan="<?echo $actual_columns_count?>"></td>

  </tr>

  <?php 



	while($row = mysql_fetch_array($result,MYSQL_ASSOC))

	{

		//fill array with current grouping fields
		foreach($group_by as $key=>$val)

		{

			$cur_group_ar[$val] = $row[$val] ;

		}					



		//print group by fields in case of grouping values variation
		if(count($last_group_ar)!=0)

		{

			$diff_index = grouping_diff_index($cur_group_ar,$last_group_ar);

		}

		else

		{

			$diff_index = 0 ;

		}



		if($diff_index !=-1)

		{

			for($i=$diff_index;$i<count($group_by);$i++) 

			{

				if($i ==0 && $diff_index==0)

					echo "<tr><td class='MainGroup'  colspan=". $actual_columns_count ." >" .$group_by[$i] .": " . $row[$group_by[$i] ] . " </td></tr>";

				else

					echo "<tr><td class='SubGroup'  colspan=". $actual_columns_count ." >" . $group_by[$i] .": " . $row[$group_by[$i] ] . "</td></tr>";

			}



     //echo"<tr><td height='15' $span class='TableHeader'></td></tr>";





	if($cur_row==0)		

	{

?>



  <tr>

    <td><table

    <?php

//width of report

if($print != 0)

  echo "width='500'";

else

  echo "width ='100%'";

?>



     border="0" cellspacing="0" cellpadding="2" align='center'>

   <?php }

 } ?> 



<?php 

		//print table columns

		if( ($group_by_count>0 && $diff_index !=-1) || $cur_row==0  ) //if there is a change in grouping

		{

			$i = 0;

			foreach($actual_fields as $key=>$val)

			{

				if($i==0) echo "<tr>";

				echo "<td align='center' class='ColumnHeader'>$val</td>";

				if($i == $actual_columns_count -1)  echo "</tr>";

				$i++;

			}

		}





		//print row data

		echo "<tr>";

		foreach($actual_fields as $key=>$val)

		{
				if($toggle_row == 0)

					if(empty($row[$val]))

	        			echo "<td align='center' class='TableCell'>" . " " . "</td>";

					else

        				echo "<td align='center' class='TableCell'>" . $row[$val] . "</td>";

				else

					if(empty($row[$val]))					

						echo "<td align='center' class='AlternateTableCell'>" . " "  ."</td>";					

					else

						echo "<td align='center' class='AlternateTableCell'>" . $row[$val] ."</td>";											

		}

		echo "</tr>";



		//change toggling of rows

	  	if($toggle_row == 0)

			$toggle_row = 1;

		else

			$toggle_row =0;



		//update new grouping

		if($diff_index !=-1)

		{

			$last_group_ar  =array();

			foreach($group_by as $key=>$val)

			{

				$last_group_ar[$val] = $row[$val] ;

			}

		}



		//increment current rows

		$cur_row ++;

	}

?>



    </table></td>

  </tr>

  <!-- ******************** start custom footer ******************** !-->

  <?php

  if(!empty($footer))

  {

  echo "<tr><td > $footer</td></tr>";

  }

  ?>

  <!-- ******************** end custom footer ******************** !-->

  <tr>

    <td class="TableFooter"> </td>

  </tr>

</table>

<!-- ************************* Show print Dialog **************************** !-->

<?php 

//show print dialog in case of print mode $$$

if($print==3)

{

?>

<script>

		window.print();

</script>

<?php 

}

?>

<!-- ************************* End Of Show print Dialog ********************* !-->





</body>

</html>

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.