Jump to content

[SOLVED] GMT time


LamivNahdus

Recommended Posts

Hello,

          I have hosted my site in a different country. But i need the time to represent as in my own country. For that i have to get the GMT time. So that i can add my country's GMT offset to it. I got details about gmmktime() and gmdate() functions. But i need to get current timestamp(in the server) in GMT. how can i get that?

please help me....

Link to comment
https://forums.phpfreaks.com/topic/102719-solved-gmt-time/
Share on other sites

straight from PHPit:

<?php

// Get timestamp in server timezone
$time = time();
echo "Server time: " . date("d/m/Y H:i", $time) . "";

// Get GMT timestamp
$gm_time = $time - date('Z', $time);
echo "GMT time: " . date("d/m/Y H:i", $gm_time) . "";

// Difference:
$diff = ($time - $gm_time)/3600;

if ($diff < 0) {
        $timezone = 'GMT' . $diff;
} else {
        $timezone = 'GMT+' . $diff;
}

echo 'Server timezone: ' . date('T', $time) . '';
echo 'Server timezone offset: ' . $timezone;

?>

Link to comment
https://forums.phpfreaks.com/topic/102719-solved-gmt-time/#findComment-525977
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.