Саша Стаменковић a écrit :
First example is very comfusing, 2nd have sense, but I think have one error. Trying to correct:

$date = new Zend_Date();
$date->setTimezone('UTC');
$date->set($dbRow->date, 'YYYY-MM-dd HH:mm:ss');
$nowDate = new Zend_Date();
$nowDate->setTimezone('UTC');

$timeSlice = $nowDate->subDate($date);
$timeSlice->get('dd HH:mm:ss');


Unfortunatly it don't work.
Look at:

$now = new Zend_Date();
$minOne = new Zend_Date();
$minOne->subHour(4);
$now->subDate($minOne);
echo $now->get('dd'); //03 should be 00


Best Regards

PS. Could the mailing list manager fix the reply-to header so that it reply to the mailing-list insthead of the original sender. Thanks

Regards,
Saša Stamenković


On Wed, Aug 12, 2009 at 3:08 PM, Mathieu Suen <[email protected] <mailto:[email protected]>> wrote:

    So if I retrive a date from a MySQL DB I have to do the following?

    $date = new Zend_Date();
    $date->setTimezone('UTC');
    $date->set($dbRow->date, 'YYYY-MM-dd HH:mm:ss');
    $created_at = new Zend_Measure_Time($date->getTimestamp());
    $nowDate = new Zend_Date();
    $nowDate->setTimezone('UTC');
    $now = new Zend_Measure_Time($nowDate->getTimestamp());
    $now->sub($created_at);
    $now->convertTo(Zend_Measure_Time::SECOND);
    ...
    ...

    I find it extremly heave.
    I would expect something like this:

    $date = new Zend_Date();
    $date->setTimezone('UTC');
    $date->set($dbRow->date, 'YYYY-MM-dd HH:mm:ss');
    $nowDate = new Zend_Date();
    $nowDate->setTimezone('UTC');

    $timeSlice = $nowDate->subDate($nowDate);
    $timeSlice->get('dd HH:mm:ss');

    Саша Стаменковић a écrit :

        Maybe this snippet can give you idea
        
http://www.zfsnippets.com/snippets/view/id/39/time-measurement-with-zendmeasuretime

        Regards,
        Saša Stamenković


        On Wed, Aug 12, 2009 at 2:11 PM, Mathieu Suen
        <[email protected] <mailto:[email protected]>
        <mailto:[email protected]
        <mailto:[email protected]>>> wrote:

           Hi,

           Using Zend_Date how could we get the difference between 2 date.
           Let's say I want the number of day?

           Thanks

           --    -- Mathieu Suen
           --




-- -- Mathieu Suen
    --




--
-- Mathieu Suen
--

Reply via email to