jd2007 Posted September 16, 2007 Share Posted September 16, 2007 how to convert a date to a GMT date ? Link to comment https://forums.phpfreaks.com/topic/69549-hi-how-to-convert-a-date-to-a-gmt-date/ Share on other sites More sharing options...
MasterACE14 Posted September 16, 2007 Share Posted September 16, 2007 I came across this while browsing the net: If you want to define your own time without having trouble with the server time you could do this; <?php $timeZoneOffset = +1; //timezone where the user is (use an additional script to determine this variable) $H = (date('H')+date('O'))+$timeZoneOffset; //hour $i = date('i'); //minutes $s = date('s'); //seconds $m = date('m'); //month $d = date('d') //day $Y = date('Y') //year $date = date('Y-m-d, H:i:s',mktime($H,$i,$s,$m,$d,$Y)); // will output somthing like 2007-09-13, 03:52:05 ?> Regards ACE Link to comment https://forums.phpfreaks.com/topic/69549-hi-how-to-convert-a-date-to-a-gmt-date/#findComment-349463 Share on other sites More sharing options...
rarebit Posted September 16, 2007 Share Posted September 16, 2007 If your starting from scratch or just using unix time (best), to display you can easily format with date: $time = time(); echo date("m:d:y@G:i:s", $time); echo date("j \of F Y, \a\\t g.i a", $time); echo date("r", $time); See http://uk3.php.net/manual/en/function.date.php for details... Link to comment https://forums.phpfreaks.com/topic/69549-hi-how-to-convert-a-date-to-a-gmt-date/#findComment-349475 Share on other sites More sharing options...
php_joe Posted September 16, 2007 Share Posted September 16, 2007 <?php ///////// To display GM date ///////// echo gmdate("M d Y H:i:s"); ///////// To convert a date to GM date ///////// echo gmdate("M d Y H:i:s", mktime($hour, $minute, $second, $month, $day, $year)); ?> Link to comment https://forums.phpfreaks.com/topic/69549-hi-how-to-convert-a-date-to-a-gmt-date/#findComment-349489 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.