function time_to_date($to = "2005/12/17 10:00:00", $from = "nothing") {
// "$to" english: time_to_date("2002/09/01 09:22:50")
// "$from" date (englisch) where the count began!
Not typed, he gets the actually date!
$event = "Bis auf weiteres Verschoben!";
$output = 0; // Set to 1, and the output will be like "1/07/02 10:00:00"
setlocale (LC_TIME, "de_DE");
if ($from == "nothing") {
$from = date("Y/m/d H:i:s");
}
$from_time_date = explode(" ", $from);
$from_date = explode("/", $from_time_date[0]);
$from_time = explode(":", $from_time_date[1]);
$from_y = $from_date[0];
$from_m = $from_date[1];
$from_d = $from_date[2];
$from_h = $from_time[0];
$from_i = $from_time[1];
$from_s = $from_time[2];
// setting up $TO
if ($to == "nothing") {
return "<B>Please enter a date!<BR>".$to;
}
$to_time_date = explode(" ", $to);
$to_date = explode("/", $to_time_date[0]);
$to_time = explode(":", $to_time_date[1]);
$to_y = $to_date[0];
$to_m = $to_date[1];
$to_d = $to_date[2];
$to_h = $to_time[0];
$to_i = $to_time[1];
$to_s = $to_time[2];
//unix timestamp
$from = mktime($from_h, $from_i, $from_s, $from_m, $from_d, $from_y);
$to = mktime($to_h, $to_i, $to_s, $to_m, $to_d, $to_y);
// Older Timestamp?
if (($to < $from) or ($to == $from)) {
return($event);
}
// Writing the new Unix Timestamp
$end = $to - $from;
$end = ereg_replace("-","", $end);
// generate output!
$y = strftime("%Y", $end);
$y = substr($y, 3);
$m = strftime("%m", $end); $m--;
$d = strftime("%d", $end); $d--;
$h = strftime("%H", $end); $h--;
$i = strftime("%M", $end);
$s = strftime("%S", $end);
if (strstr($y, "-")) { $y = 00; }
if (strstr($m, "-")) { $m = 00; }
if (strstr($d, "-")) { $d = 00; }
if (strstr($h, "-")) { $h = 00; }
if (strstr($i, "-")) { $i = 00; }
if (strstr($s, "-")) { $s = 00; }
if ($output == 1) {
$new_date = $y."/".$m."/".$d." ".$h.":".$i.":".$s;
}
else {
$new_date = $m."m ".$d."d ".$h."h ".$i."m ".$s."s";
}
// output the stuff!
return($new_date);
}