$d = new DateTime("now", new DateTimeZone("Africa/Johannesburg")); echo $d->format("r");
gives
Mon, 07 Jun 2010 02:02:12 +0200
You can change the format. See http://www.php.net/manual/en/function.date.php
time() gives the number of seconds since January 1, 1970 00:00:00 GMT (excluding seconds of a jump), so it does not depend on the time zone.
EDIT: for the countdown you can:
$tz = new DateTimeZone("Africa/Johannesburg"); $now = new DateTime("now", $tz); $start = new DateTime("2010-06-11 16:00:00", $tz); $diff = $start->diff($now); echo "Days: " . $diff->format("%d") . "\n"; echo "Hours: " . $diff->format("%h") . "\n"; echo "Minutes: " . $diff->format("%i") . "\n"; echo "Seconds: " . $diff->format("%s") . "\n";
Artefacto
source share