MySQL Forums
Forum List  »  PHP

Useful Snippet
Posted by: Martyn Coupland
Date: June 14, 2005 09:14AM

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;




echo "Posted: ".$mysql['hour'].":".$mysql['minute']."\n";


Hope this helps people...

Martyn Coupland
Development Officer

Options: ReplyQuote

Written By
Useful Snippet
June 14, 2005 09:14AM
June 15, 2005 10:20AM
June 15, 2005 12:37PM

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.