I have problem mktime AM PM


#1

Hello All,
I am new to this forum, can you please help me?
I am doing a programe with Time Zone.
The code I did it has a cofution of AM and PM
I am using mktime() to + or - the zone.
for the result I am getting if the corect time is AM but after mktime() its giving PM.
Then I just tryed as follow

$GMT_Time = date('Y-m-d h:i:s',mktime(date('h'), date('i'), date('s'), date('m'),date('d'), date('Y')));
list($year,$month,$day,$hour,$minute,$second) = explode("-",str_replace(array(" ",":"),"-",$GMT_Time));
print date('D, M d, y : h:i:a',mktime($hour,$minute,$second, $month,$day,$year);

Above code is just mktime() of currunt time of the server, but that also giving for AM its giving PM

Please help me.
Thank You,
Safras Ahamed.


#2

I fornd a solution, but its not a good solution
I have just added +12 as follows its showing correct date time.
then is it mean there is a bug in mktime()

$GMT_Time = date('Y-m-d h:i:s',mktime(date('h'), date('i'), date('s'), date('m'),date('d'), date('Y'))); 
list($year,$month,$day,$hour,$minute,$second) = explode("-",str_replace(array(" ",":"),"-",$GMT_Time)); 
print date('D, M d, y : h:i:a',mktime($hour+12,$minute,$second, $month,$day,$year); 

#3

First of all: mktime() is not buggy.

What exactly are you trying to achieve here? Displaying the server’s time in a certain format? I’d say date() should be plenty for that.