GMT TIME
No matter the server is in which GMT time zone here is extremely easy way to get time and date for any time zone. This is done with time() and gmdate() function. gmdate() function normally give us GMT time but by doing a trick with time() function we can get GMT+N or GMT-N means we can get time for any GMT time zone.
For example you have to get time for GMT+5 we will do it like following
$offset=5*60*60; //converting 5 hours to seconds.
$dateFormat="d-m-Y H:i";
$timeNdate=gmdate($dateFormat, time()+$offset);
?>
Now if you have to get the time which is GMT-5 now we will just subtract the offset from the time() instead of adding into time like in following example we are getting time for GMT-4
$offset=4*60*60; //converting 5 hours to seconds.
$dateFormat="d-m-Y H:i";
$timeNdate=gmdate($dateFormat, time()-$offset);
?>
-12 = GMT - 12 Hours
-11 = GMT - 11 Hours
-10 = GMT - 10 Hours
-9 = GMT - 9 Hours
-8 = GMT - 8 Hours
-7 = GMT - 7 Hours
-6 = GMT - 6 Hours
-5 = GMT - 5 Hours
-4 = GMT - 4 Hours
-3.5 = GMT - 3.5 Hours
-3 = GMT - 3 Hours
-2 = GMT - 2 Hours
-1 = GMT - 1 Hours
0 = GMT
1 = GMT + 1 Hour
2 = GMT + 2 Hours
3 = GMT + 3 Hours
3.5 = GMT + 3.5 Hours
4 = GMT + 4 Hours
4.5 = GMT + 4.5 Hours
5 = GMT + 5 Hours
5.5 = GMT + 5.5 Hours
6 = GMT + 6 Hours
6.5 = GMT + 6.5 Hours
7 = GMT + 7 Hours
8 = GMT + 8 Hours
9 = GMT + 9 Hours
9.5 = GMT + 9.5 Hours
10 = GMT + 10 Hours
11 = GMT + 11 Hours
12 = GMT + 12 Hours
13 = GMT + 13 Hours
For example you have to get time for GMT+5 we will do it like following
$offset=5*60*60; //converting 5 hours to seconds.
$dateFormat="d-m-Y H:i";
$timeNdate=gmdate($dateFormat, time()+$offset);
?>
Now if you have to get the time which is GMT-5 now we will just subtract the offset from the time() instead of adding into time like in following example we are getting time for GMT-4
$offset=4*60*60; //converting 5 hours to seconds.
$dateFormat="d-m-Y H:i";
$timeNdate=gmdate($dateFormat, time()-$offset);
?>
-12 = GMT - 12 Hours
-11 = GMT - 11 Hours
-10 = GMT - 10 Hours
-9 = GMT - 9 Hours
-8 = GMT - 8 Hours
-7 = GMT - 7 Hours
-6 = GMT - 6 Hours
-5 = GMT - 5 Hours
-4 = GMT - 4 Hours
-3.5 = GMT - 3.5 Hours
-3 = GMT - 3 Hours
-2 = GMT - 2 Hours
-1 = GMT - 1 Hours
0 = GMT
1 = GMT + 1 Hour
2 = GMT + 2 Hours
3 = GMT + 3 Hours
3.5 = GMT + 3.5 Hours
4 = GMT + 4 Hours
4.5 = GMT + 4.5 Hours
5 = GMT + 5 Hours
5.5 = GMT + 5.5 Hours
6 = GMT + 6 Hours
6.5 = GMT + 6.5 Hours
7 = GMT + 7 Hours
8 = GMT + 8 Hours
9 = GMT + 9 Hours
9.5 = GMT + 9.5 Hours
10 = GMT + 10 Hours
11 = GMT + 11 Hours
12 = GMT + 12 Hours
13 = GMT + 13 Hours