Looks like you didn't use my piece of code to reproduce the problem:

$date = new Zend_Date(null, null, $locale);
$date->setTimestamp(1256198496);
echo $date->getDate()->toString(Zend_Date::DATES);

Using this:

$date = new Zend_Date(null, null, $locale);
$date->setTimestamp(1256198496);
echo $date->getDate()->toString();

I get

21 Oct 2009 23:00:00

which is again wrong.

If I understand well, Zend_Date is determining which timezone to use by
locale passed in constructor. But by looking in constructor docblock I
figured that it's read from PHP

/**
     * Generates the standard date object, could be a unix timestamp,
localized date,
     * string, integer, array and so on. Also parts of dates or time are
supported
     * Always set the default timezone:
http://php.net/date_default_timezone_set
     * For example, in your bootstrap:
date_default_timezone_set('America/Los_Angeles');
     * For detailed instructions please look in the docu.
     *
     * @param  string|integer|Zend_Date|array  $date    OPTIONAL Date value
or value of date part to set
     *                                                 ,depending on $part.
If null the actual time is set
     * @param  string                          $part    OPTIONAL Defines the
input format of $date
     * @param  string|Zend_Locale              $locale  OPTIONAL Locale for
parsing input
     * @return Zend_Date
     * @throws Zend_Date_Exception
     */
    public function __construct($date = null, $part = null, $locale = null)

and in line #184 it's obvious

// set the timezone and offset for $this
$zone = @date_default_timezone_get();
$this->setTimezone($zone);

I use zf 1.9.5.

Regards,
Saša Stamenković


On Wed, Nov 11, 2009 at 9:32 AM, Thomas Weidner <[email protected]>wrote:

> Creating the instance affects the timezone.
> Using set methods affect the timezone.
> The manual states multiple ways (more than 20?) to affect the timezone.
>
> In the code you gave the locale affects the timezone.
> And we still don't know how your complete date looks like.
> So all we can do is prediction.
>
> And using your code on both locales I get:
> sr_RS: string '2009-10-22T10:01:36+02:00' (length=25)
> en_GB:string '2009-10-22T10:01:36+02:00' (length=25)
>
>
> Greetings
> Thomas Weidner, I18N Team Leader, Zend Framework
> http://www.thomasweidner.com
>
> ----- Original Message ----- From: "Саша Стаменковић" <[email protected]>
> To: "Thomas Weidner" <[email protected]>
>
> Cc: <[email protected]>
> Sent: Wednesday, November 11, 2009 8:47 AM
>
> Subject: Re: [fw-general] Zend_Date problem
>
>
> How do I set timezone to affect Zend_Date component?
> I use zend date to create view helper for date formatting.
>
> Regards,
> Saša Stamenković
>
>
> On Wed, Nov 11, 2009 at 8:21 AM, Thomas Weidner <[email protected]
> >wrote:
>
>  Sorry, but date_default_timezone_set has no effect on the timezone which
>> is
>> actually used by the instance of Zend_Date nor has it effect on DST.
>> My question was related to the instance not your environment.
>>
>> Why don't you output all dateparts from the instance instead of giving
>> partitial informations ?
>>
>> Greetings
>> Thomas Weidner, I18N Team Leader, Zend Framework
>> http://www.thomasweidner.com
>>
>> ----- Original Message ----- From: "Саша Стаменковић" <[email protected]
>> >
>> To: "kobsu" <[email protected]>
>> Cc: <[email protected]>
>> Sent: Wednesday, November 11, 2009 7:59 AM
>> Subject: Re: [fw-general] Zend_Date problem
>>
>>
>>
>> @Thomas Weidner
>> *
>> *
>> date_default_timezone_set('Europe/Stockholm'); is in bootstrap.
>>
>> @kobsu
>> *
>> *
>> *Same result :(
>> *
>> Regards,
>> Saša Stamenković
>>
>>
>> On Tue, Nov 10, 2009 at 6:20 PM, kobsu <[email protected]> wrote:
>>
>>
>>  Try
>>> Zend_Date::setOptions(array('fix_dst' => true));
>>>
>>> before
>>> $date = new Zend_Date();
>>>
>>>
>>> umpirsky wrote:
>>> >
>>> > Hi zf community.
>>> >
>>> > This code:
>>> >
>>> > $date = new Zend_Date(null, null, $locale);
>>> > $date->setTimestamp(1256198496);
>>> > echo $date->getDate()->toString(Zend_Date::DATES);
>>> >
>>> > gives date 21.10.2009. for sr_RS locale (similar for other locales), >
>>> for
>>> > en_GB it gives 21 Oct 2009.
>>> > I expect 22 Oct 2009. it's whole day missed?!?!?
>>> >
>>> > Any idea?
>>> >
>>>
>>> --
>>> View this message in context:
>>> http://old.nabble.com/Zend_Date-problem-tp26283342p26287337.html
>>> Sent from the Zend Framework mailing list archive at Nabble.com.
>>>
>>>
>>>
>>>
>>
>

Reply via email to