Date time issue, timezone set

Hello All,

I’ve created a app in yii. it’s working well but an issue m facing is timezone. I’m running this application on localhost on my development machine.

When I’m printing date and time using [color="#4169E1"]date[color="#000000"]([/color][color="#2E8B57"]“l, F dS h:i A T”[/color][color="#000000"])[/color][/color] function, but output time didn’t matching with my local time.

See:

output by php date() function is: [color="#FF0000"]Tuesday, August 14th 05:14 PM IST[/color]

and my system time is [color="#008000"]Tuesday, August 14th 01:44 PM IST[/color]

there is [color="#FF0000"]4:30[/color] hours difference.

PHP time should be match with my machine time.

Timezone that I’ve set is [color="#F4A460"]‘Asia/Kolkata’[/color]

Above all was working well when I was using [color="#483D8B"]LocalTime[/color] and [color="#483D8B"]DefaultDateTimeParser[/color]. [color="#483D8B"]LocalTime[/color] class that was I found on Yii Wiki.

I removed it because it uses PHP [color="#483D8B"]DateTime[/color] class and my server PHP version is 5.1.6.

Please help me to solve it.

Thanks

Hi!

Have you tried to define the timezone on config file ? You can do it adding




...

'timeZone' => 'your time zone here',

...



I did, but the problem is same. It doesn’t changes.

Have you changed the time zone on php.ini ?

I had the same problem some time ago, but i solved it only by adding the ‘timezone’ on yii config file (main.php). You can try and change the time zone on php.ini and then restart the web server.

Let me know if it worked for you!

Solved:

actually problem was some where else,

I’ve created a static function in a class that was returning date as:




$format = "l, F dS h:i A T";

return date($format, strtotime(date($format))); // This was returning on some mixed conditions


/* Correct is */

return date($format, strtotime($date));



[color="#FF0000"]But, why above code adding +04:30 Hrs [/color]

Alright, glad to know that you solved the problem! :)