Click here to Skip to main content
16,012,166 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am now in a place on time under gmt+6

I want to see my time in 24 hour time format. I wrote the code :
PHP
date_default_timezone_set('Etc/GMT+6');

echo $date2=date("H:i:s");


But it shows time in 12 hour format like now 10:02:00 .

but whet I write only the following line

echo $date2=date("H:i:s");
It shows me time in 12 hour format but always take 4 hour less . i.e it want to show 22:02:00 but it shows 18:02:00

I want solution. Please put your ans.

Thanks in advance.......
Posted
Updated 6-Jun-14 7:11am
v2

It is correct, it showed 10:02:00 hrs, just happen to be the same as 12 hour format. You can verify the current date time by entering out 'Etc/GMT+6' at timezoneconverter.com[^]. At this moment, it show Fri 6-Jun-2014 11:09 A.M.
 
Share this answer
 
v2
Comments
nest101234 6-Jun-14 13:10pm    
but I want to show 22:02:00
Peter Leow 6-Jun-14 13:12pm    
You will have to wait for 12 hours from now. The date("H:i:s") returns the current time of the timezone in 24 hours format.
PHP
$timezone  = +6; //(GMT +6:00)
echo gmdate("H:i:s", time() + 3600*($timezone+date("I")));
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900