function str2timestamp($str) { if (empty($str)) { return 0; } //2001-12-12 12:12:12 if (preg_match('/^(/d{2,4})/-(/d{1,2})-(/d{1,2}) (/d{1,2}):(/d{1,2}):(/d{1,2})$/', $str, $matches)) { $y = $matches[1]; $m = $matches[2]; $d = $matches[3]; $h = $matches[4]; $i = $matches[5]; $s = $matches[6]; } else { return 0; } $timestamp = mktime($h, $i, $s, $m, $d, $y); if(0) { echo "<br>str: {$str}<br>y: {$y}<br>m: {$m}<br>d: {$d}<br>h: {$h}<br>i: {$i}<br>s: {$s}<br>timestamp: {$timestamp}"; } return $timestamp; }