Jump to content

[SOLVED] Probably dead easy, but displaying date from mysql in while


richrock

Recommended Posts

,

 

Having a little difficulty in displaying modified dates on a page - they're all stuck at 1970 and all the tutorials I find just talk about using date() without the results of a mysql query.

 

Hi $getBids = "SELECT * FROM jos_bids ORDER BY id_offer ASC";
$resBids = mysql_query($getBids) or die(mysql_error());

// generate the rows

	while ($row_bids = mysql_fetch_array($resBids)) {

		$id_offer = $row_bids['id_offer'];
		$userid = $row_bids['userid'];
		$bid_price = $row_bids['bid_price'];
		$date_placed = date("d.m.Y",$row_bids['modified']);
		$time_placed = date("H.i.s",$row_bids['modified']);

 

As you can see, I've placed the date in the while function.  However, when I echo $date_placed and $time_placed, I get 01.01.1970, and 01.33.28 respectively.  How do I get the actual real dates displayed?

$row_bids['modified'] would need to be a Unix timestamp for that code to work.

 

If $row_bids['modified'] is a mysql DATETIME, just use the mysql DATE_FORMAT() function in your query to give you the output in any format you want.

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.