Yii Framework Forum: Possible Timezone Bug In Cdateformatter? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Possible Timezone Bug In Cdateformatter? Rate Topic: -----

#1 User is offline   InsaneWookie 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 04-September 12

Posted 02 November 2012 - 12:05 AM

I think I have come across a bug in the date formatting

We store all our date times in UTC in the database (without time zone)

Easiest to explain if I give an example
I'm trying to do something like this:

$dt = new DateTime($model->lastupdated, new DateTimeZone('UTC'));
echo Yii::app()->dateFormatter->formatDateTime($dt->getTimestamp(), 'short');
//outputs: "11/2/12 3:35:45 PM"
echo $dt->format('c'); 
//outputs: 2012-11-02T02:35:45+00:00

$model->lastupdated is a postgres date in the format "2012-11-02 02:35:45.446"

Problem is its not outputting the correct time
Its converting the time to the local time zone set in php.ini (date.timezone)

I think I have tracked it down to the call to CTimestamp::getDate()
Specifically the php function getdate() which seems to be converting the timestamp to local time

I think the getdate() function should be replace with a custom version that does no time zone conversions

Yii version: 1.1.11
PHP: 5.3.6
OS: Windows 7
Webserver: Apache 2.2.17
Browser: Chrome Version 22.0.1229.94 m


Share this topic:

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users