Zend_Date get('Y-m-d') bug?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Zend_Date get('Y-m-d') bug?

András Csányi
Hi all!

I want to know what is the date of the first day of the week. I did this:
$currDate = new Zend_Date();
    $currDate->sub($currDate->get(Zend_Date::WEEKDAY_DIGIT)- 1,Zend_Date::DAY);
    var_dump($currDate->get('Y-m-d'));

But, the result is not so good. The year and the day is good. The
month is replaced to minutes.
2010-38-12; actual time here: 13:38

I watched in the documentation and it should be good.
(http://hu.php.net/manual/en/function.date.php)

If I get the date through __toString() good, but I want to avoid
formatting the string.

Did I somethign wrong?

Thanks for the help!

--
- -
--  Csanyi Andras  -- http://sayusi.hu -- Sayusi Ando
--  "Bízzál Istenben és tartsd szárazon a puskaport!".-- Cromwell
Reply | Threaded
Open this post in threaded view
|

Re: Zend_Date get('Y-m-d') bug?

Jurian Sluiman-4
On Saturday 17 Apr 2010 13:40:43 András Csányi wrote:

> Hi all!
>
> I want to know what is the date of the first day of the week. I did this:
> $currDate = new Zend_Date();
>     $currDate->sub($currDate->get(Zend_Date::WEEKDAY_DIGIT)-
> 1,Zend_Date::DAY); var_dump($currDate->get('Y-m-d'));
>
> But, the result is not so good. The year and the day is good. The
> month is replaced to minutes.
> 2010-38-12; actual time here: 13:38
>
> I watched in the documentation and it should be good.
> (http://hu.php.net/manual/en/function.date.php)
>
> If I get the date through __toString() good, but I want to avoid
> formatting the string.
>
> Did I somethign wrong?
>
> Thanks for the help!

No its' not a bug, you're using the minute constant. A capital M is the
constant for the month.

The Zend_Date constants differ from the php constants. Visit the documentation
for more information:
http://framework.zend.com/manual/en/zend.date.constants.html and specific the
section "Self-Defined OUTPUT Formats with ISO"

Regards, Jurian
--
Jurian Sluiman
CTO Soflomo V.O.F.
http://soflomo.com
Reply | Threaded
Open this post in threaded view
|

Re: Zend_Date get('Y-m-d') bug?

till
On Sat, Apr 17, 2010 at 1:46 PM, Jurian Sluiman
<[hidden email]> wrote:

> On Saturday 17 Apr 2010 13:40:43 András Csányi wrote:
>> Hi all!
>>
>> I want to know what is the date of the first day of the week. I did this:
>> $currDate = new Zend_Date();
>>     $currDate->sub($currDate->get(Zend_Date::WEEKDAY_DIGIT)-
>> 1,Zend_Date::DAY); var_dump($currDate->get('Y-m-d'));
>>
>> But, the result is not so good. The year and the day is good. The
>> month is replaced to minutes.
>> 2010-38-12; actual time here: 13:38
>>
>> I watched in the documentation and it should be good.
>> (http://hu.php.net/manual/en/function.date.php)
>>
>> If I get the date through __toString() good, but I want to avoid
>> formatting the string.
>>
>> Did I somethign wrong?
>>
>> Thanks for the help!
>
> No its' not a bug, you're using the minute constant. A capital M is the
> constant for the month.
>
> The Zend_Date constants differ from the php constants. Visit the documentation
> for more information:
> http://framework.zend.com/manual/en/zend.date.constants.html and specific the
> section "Self-Defined OUTPUT Formats with ISO"
>
> Regards, Jurian

The easiest way is still to do the following:
Zend_Date::setOptions(array('format_type' => 'php'));

... and then use PHP-like identifiers to do your date juggling.

Till
Reply | Threaded
Open this post in threaded view
|

Re: Zend_Date get('Y-m-d') bug?

András Csányi
On 17 April 2010 14:03, till <[hidden email]> wrote:
>
> The easiest way is still to do the following:
> Zend_Date::setOptions(array('format_type' => 'php'));
>
> ... and then use PHP-like identifiers to do your date juggling.

It sounds like a title of a motivation picture. :)

--
- -
--  Csanyi Andras  -- http://sayusi.hu -- Sayusi Ando
--  "Bízzál Istenben és tartsd szárazon a puskaport!".-- Cromwell