Zend - The PHP Company




Conversion

Add Code


timestamp_db_php  

Type: code fragment
Added by: chrisshaffer
Entered: 12/12/2002
Last modified: 02/11/2001
Rating: - (fewer than 3 votes)
Views: 6586
Takes a MySQL formated timestamp value (YYYYMMDDhhmmss) and converts it to a humman readable date using the date() function.


<?php
function timestamp_db_php($date
{
    
$year   substr($date,0,4);
    
$month  substr($date,4,2);
    
$day    substr($date,6,2);
    
$hour   substr($date,8,2);
    
$minute substr($date,10,2);
    
$second substr($date,12,2);
    
//$epoch = date("U", mktime($time[0],$time[1],$time[2],$datebreak[1],$datebreak[2],$datebreak[0])); 
      
$datetime $month."-".$day."-".$year." &nbsp;".$hour.":".$minute.":".$second." ";
      return 
$datetime

?>


Usage Example


timestamp_db_php("20021215153817"); would return "12-15-2002  15:38:17".


Rate This Script





Search



This Category All Categories