phpvasu Posted August 21, 2007 Share Posted August 21, 2007 How can I get UTC time in PHP 4? Quote Link to comment https://forums.phpfreaks.com/topic/66035-solved-how-to-get-utc-time-in-php-4/ Share on other sites More sharing options...
nathanmaxsonadil Posted August 21, 2007 Share Posted August 21, 2007 you could use this if you were using php 5.1 and higher date_default_timezone_set('UTC'); but I dont think it possible on php 4 Quote Link to comment https://forums.phpfreaks.com/topic/66035-solved-how-to-get-utc-time-in-php-4/#findComment-330236 Share on other sites More sharing options...
phpvasu Posted August 21, 2007 Author Share Posted August 21, 2007 We don't have PHP 5 installed in our server. Getting PHP 5 on the server is not an immediate solution. I need to get UTC time in PHP 4 at the moment. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/66035-solved-how-to-get-utc-time-in-php-4/#findComment-330240 Share on other sites More sharing options...
GingerRobot Posted August 21, 2007 Share Posted August 21, 2007 Well, you could use the O or Z format characters to get a differance between your timezone and GMT and work with that. www.php.net/date Quote Link to comment https://forums.phpfreaks.com/topic/66035-solved-how-to-get-utc-time-in-php-4/#findComment-330241 Share on other sites More sharing options...
GingerRobot Posted August 21, 2007 Share Posted August 21, 2007 Rather like: <?php $timestamp = time(); $offset = date('Z'); $gmt_timestamp = $timestamp - $offset; echo date('H:i:s',$gmt_timestamp); ?> Quote Link to comment https://forums.phpfreaks.com/topic/66035-solved-how-to-get-utc-time-in-php-4/#findComment-330248 Share on other sites More sharing options...
phpvasu Posted August 21, 2007 Author Share Posted August 21, 2007 Ben, echo gmdate('H:i:s'); is also yielding the same result. How different is your method? Will it be accurate to gmdate then? Quote Link to comment https://forums.phpfreaks.com/topic/66035-solved-how-to-get-utc-time-in-php-4/#findComment-330265 Share on other sites More sharing options...
GingerRobot Posted August 21, 2007 Share Posted August 21, 2007 Hmm, didn't notice that was a php 4 function too. Its exactly the same, just much shorter! Quote Link to comment https://forums.phpfreaks.com/topic/66035-solved-how-to-get-utc-time-in-php-4/#findComment-330275 Share on other sites More sharing options...
phpvasu Posted August 21, 2007 Author Share Posted August 21, 2007 before concluding, one more question. Is there any difference between GMT time and UTC time? Quote Link to comment https://forums.phpfreaks.com/topic/66035-solved-how-to-get-utc-time-in-php-4/#findComment-330288 Share on other sites More sharing options...
GingerRobot Posted August 21, 2007 Share Posted August 21, 2007 Not that im aware of. A google define seems to suggest they are the same too Quote Link to comment https://forums.phpfreaks.com/topic/66035-solved-how-to-get-utc-time-in-php-4/#findComment-330295 Share on other sites More sharing options...
phpvasu Posted August 21, 2007 Author Share Posted August 21, 2007 thanks Ben. So, I will go with gmdate then. Quote Link to comment https://forums.phpfreaks.com/topic/66035-solved-how-to-get-utc-time-in-php-4/#findComment-330313 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.