PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Date and Time » Date » Bug #309

Undefined object error in getDate()

Details

Submitted2003-11-27 17:05 UTC
Frommike dot carter at personalmedicaladvisor dot co dot uk
StatusBogus
PackageDate
PHP Version4.3.3
OSRedhat 9
Roadmaps(Not assigned)

Comments

[2003-11-27 17:05 UTC] mike dot carter at personalmedicaladvisor dot co dot uk

Description:
------------
Calling the getDate() method causes an error in the class.

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

$values['dob']['d'] = "5";
$values['dob']['m'] = "2";
$values['dob']['Y'] = "1952";

$dateObj = new Date;
$dateObj->setYear($values['dob']['Y']);
$dateObj->setMonth($values['dob']['m']);
$dateObj->setDay($values['dob']['d']);
$dateObj->setHour(12);
$dateObj->setMinute(0);
$dateObj->setSecond(0);
$dateObj->setTZ('UTC');

var_dump($dateObj->getDate(DATE_FORMAT_ISO_BASIC));
?>

Expected result:
----------------
A date in the format "19520205T120000Z" based on the values passed in.

Actual result:
--------------
Fatal error: Call to a member function on a non-object in /usr/local/lib/php/Date.php on line 200

[2003-11-27 17:08 UTC] mike dot carter at personalmedicaladvisor dot co dot uk

Class version string (from CVS) was:

// $Id: Date.php,v 1.17 2003/11/18 02:21:44 mroch Exp $

[2003-12-03 19:58 UTC] baba at php dot net

Thank you for taking the time to write to us, but this is not
a bug.

the error in the reproduce code is:
$dateObj->setTZ('UTC');

the setTZ() method accepts a Date_TimeZone object, not a string. to set the time zone from a string, use the setTZbyID() method.

will add a paramater check to setTZ in the next cvs update.