#native_company# #native_desc#

MySQL Timestamp(14) to Human readable (HTML format) String

By Elliott Edwards
on July 13, 2001

Version: 1.0

Type: Function

Category: Calendars/Dates

License: GNU General Public License

Description: A simple converter that does a helpful (and eye-strain preventing) conversion from a MySQL Timestamp(14) to a much easier to read format. Brought to you by www.hachisoft.com

	    _/                    _/
	   _/ www.hachisoft.com  _/
	  _/      Presents:     _/ 
	 _/                    _/ 
	//MySQL Timestamp(14) to Human readable (HTML) Snippet
	//by Elliott Edwards ([email protected])
	//Standard Disclaimer:
	//This code snippet is provided AS IS. Neither Elliott Edwards nor Hachisoft are
	//to be held responsible for any failures or security flaws in this code. Use at your
	//own risk.
	//Distribution: If you want to use this code commercially or share it with friends,
	//Go Ahead. Just kindly give credit where it is due: (Elliott Edwards & Hachisoft). Thanks
	//If you appreciate this snippet or have comments, email [email protected] 
	//Updates and improvements are already in the works. see www.hachisoft.com for more details.
	//TO INSTALL: Paste this function into your php file.
	//Begin actual code///////
	//Input: A MySQL TIMESTAMP(14)
	//Output: A human-readable string version (with HTML)
	function parseTimeStamp($timestamp)
			$months = array(1=>'Jan',2=>'Feb',3=>'Mar',4=>'Apr',5=>'May',6=>'Jun',7=>'Jul',8=>'Aug',9=>'Sep',10=>'Oct',11=>'Nov',12=>'Dec');
			//Courtesy of snippet 245 by igork			
			list($year, $month, $date, $hour, $min, $sec) = sscanf($timestamp, "%4d%2d%2d%2d%2d%2d");
			if ($hour>=12)
			$hour = $hour % 12;
			if ($hour==0)
				$hour = 12;
			if ($min < 10)
				$min = "0$min";	
			if ($sec < 10)
				$sec = "0$sec";
			return "$hour:$min:<SMALL>$sec $ampm</SMALL> {$months[$month]} $date, $year";