type == 'int') { $timestamp = $buffer; // Detect TIMESTAMP(6 | 8 | 10 | 12 | 14) // TIMESTAMP (2 | 4) not supported here. // (Note: prior to MySQL 4.1, TIMESTAMP has a display size, for example // TIMESTAMP(8) means YYYYMMDD) } else if (preg_match('/^(\d{2}){3,7}$/', $buffer)) { if (strlen($buffer) == 14 || strlen($buffer) == 8) { $offset = 4; } else { $offset = 2; } $d = array(); $d['year'] = substr($buffer, 0, $offset); $d['month'] = substr($buffer, $offset, 2); $d['day'] = substr($buffer, $offset + 2, 2); $d['hour'] = substr($buffer, $offset + 4, 2); $d['minute'] = substr($buffer, $offset + 6, 2); $d['second'] = substr($buffer, $offset + 8, 2); if (checkdate($d['month'], $d['day'], $d['year'])) { $timestamp = mktime($d['hour'], $d['minute'], $d['second'], $d['month'], $d['day'], $d['year']); } // If all fails, assume one of the dozens of valid strtime() syntaxes (http://www.gnu.org/manual/tar-1.12/html_chapter/tar_7.html) } else { if (preg_match('/^[0-9]\d{1,9}$/', $buffer)) { $timestamp = (int)$buffer; } else { $timestamp = strtotime($buffer); } } // If all above failed, maybe it's a Unix timestamp already? if ($timestamp < 0 && preg_match('/^[1-9]\d{1,9}$/', $buffer)) { $timestamp = $buffer; } // Reformat a valid timestamp if ($timestamp >= 0) { $timestamp -= $options[0] * 60 * 60; $source = $buffer; if ($options[2] == 'local') { $text = PMA_localisedDate($timestamp, $options[1]); } elseif ($options[2] == 'utc') { $text = gmdate($options[1], $timestamp); } else { $text = 'INVALID DATE TYPE'; } $buffer = '' . $text . ''; } return $buffer; } ?>