Code: Select all
echo gmdate("d-M-Y H:i:s");Moderator: General Moderators
Code: Select all
echo gmdate("d-M-Y H:i:s");Code: Select all
echo date("d-M-Y H:i:s",returnLocalTime("-0700"));Code: Select all
<?php
function is_positive($foo) {
if ($foo > 0) {
return true;
} else {
return false;
}
}
// Inputs: $target_gmt Must Be Between -12 to +13
// Output: Date/Time of Target GMT
function get_worldtime($target_gmt) {
$local_gmt = substr(date("O"),0,3); // eg. +07 (Thailand)
if (!is_positive($local_gmt) && !is_positive($target_gmt)) {
// Both Are Negative
if ($target_gmt < $local_gmt) {
$time_diff = substr($target_gmt,1,2)-substr($local_gmt,1,2);
$time_diff = "-".$time_diff;
} else {
$time_diff = substr($local_gmt,1,2)-substr($target_gmt,1,2);
}
}
elseif (!is_positive($local_gmt) || !is_positive($target_gmt)) {
// Only One is Negative, Add Them
$time_diff = substr($target_gmt,1,2)+substr($local_gmt,1,2);
if (!is_positive($target_gmt)) {
$time_diff = "-".$time_diff;
}
}
elseif (is_positive($target_gmt) && is_positive($local_gmt)) {
// Both are postive, subtract them
$time_diff = $target_gmt-$local_gmt;
}
$stamp = (time() + ($time_diff*60)*60); // Target Timestamp
return date("F j, Y @ g:i A", $stamp);
}
echo get_worldtime("+10")."<br>"; // Sydney, AU
echo get_worldtime("+02")."<br>"; // Amman, JO
echo get_worldtime("-07")."<br>"; // USA MST
echo get_worldtime("-05")."<br>"; // USA EST
?>Code: Select all
#!/usr/bin/perl
use DateTime;
my $dt2 = DateTime->from_epoch( epoch => time() );
$dt2->set_time_zone('America/Denver');
print $dt2->hms;Code: Select all
<?php
putenv("TZ=US/Mountain");
echo date("M d Y H:i:s");
?>