LamivNahdus Posted April 24, 2008 Share Posted April 24, 2008 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 More sharing options...
jonsjava Posted April 24, 2008 Share Posted April 24, 2008 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 More sharing options...
LamivNahdus Posted April 25, 2008 Author Share Posted April 25, 2008 Thanks... Link to comment https://forums.phpfreaks.com/topic/102719-solved-gmt-time/#findComment-526757 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.