PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Date and Time » Date » Bug #1612

strange error on time format

Details

Submitted2004-06-11 05:33 UTC
Fromfrancis at mixmedia dot com
StatusNo Feedback
PackageDate
PHP Version4.3.4
OSredhat 9.0
Roadmaps(Not assigned)

Comments

[2004-06-11 05:33 UTC] francis at mixmedia dot com

Description:
------------
PEAR Date version: Date-1.4.3

when a FunctionA return a date string to FunctionB, the string in FunctionB is somehow different than FunctionA.

Reproduce code:
---------------
<?php
require_once 'Date.php';

echo("Pear Date testing below:<br>");
echo(getPearNowUTC());
echo("<BR>");
echo(testPear());

function testPear(){
return getPearNowUTC();
}

function getPearNowUTC(){
//get UTC second
//below is actually:
//time() - date('Z')
$now=date('Y-m-d G:i:sO');
$objDate = new Date();
$objDate->setDate($now);
$objDate->convertTZbyID('UTC');
$now=$objDate->getTime();
//get UTC second END

$now=date('Y-m-d G:i:sO', $now);

return $now;
}

echo("<br>PHP testing below:<br>");
echo(getnowPHP());
echo("<BR>");
echo(testPHP());

function testPHP(){
return getnowPHP();
}

function getnowPHP(){
$now=date('Y-m-d G:i:sO', time());

return $now;
}

?>

Expected result:
----------------
Pear Date testing below:
2004-06-11 6:12:25+0000
2004-06-11 6:12:25+0000
PHP testing below:
2004-06-11 6:12:25+0000
2004-06-11 6:12:25+0000

Actual result:
--------------
Pear Date testing below:
2004-06-11 6:12:25+0000
2004-06-11 0:00:00+0000
PHP testing below:
2004-06-11 6:12:25+0000
2004-06-11 6:12:25+0000

[2004-06-11 05:36 UTC] francis at mixmedia dot com

the function getnowPHP should be:

function getnowPHP(){
$now=date('Y-m-d G:i:sO', (time() - date('Z')));

return $now;
}

thanks

[2004-06-13 13:54 UTC] pierre at dotgeek dot org

Please provide a short script to reproduce your problem. Use only date and do not mix php date() with Date.

--Pierre

[2004-06-24 08:39 UTC] francis at mixmedia dot com

To reproduce the problem: In my first message there is already an example to do it. Or you have different result?

"Use only date and do not mix php date() with Date.", you mean using php date() and Pear Date package together is not recommended?

[2005-04-11 11:13 UTC] pierre at dotgeek dot org

As php date() supports only dates inside the unix timestamp range (and limited using certains platforms), no, you should not mix both.

Still wondering in which order the getNow* are used. A small script using only pear::date should help, and the results you expect from it.

--Pierre