Useful Snippet
This is a snippet to convert your TIMESTAMP field into variables so you can use them in a different order.
function mysql_time($timestamp)
{
//set up global
global $mysql;
//set up array
$mysql = array();
$mysql['year'] = substr($timestamp, 0, 4);
$mysql['month'] = substr($timestamp, 5, 6);
$mysql['day'] = substr($timestamp, 7, 8);
$mysql['hour'] = substr($timestamp, 9, 10);
$mysql['minute'] = substr($timestamp, 11, 12);
//return string
return $mysql;
}
Example,
<?php
mysql_time($row['posted']);
echo "Posted: ".$mysql['hour'].":".$mysql['minute']."\n";
?>
Hope this helps people...
Regards,
Martyn Coupland
Development Officer
Subject
Written By
Posted
Useful Snippet
June 14, 2005 09:14AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.