Creating a new DateTime object in PHP does not work

basitmemon786

New Member
I have the following piece of code. I've recorded the output as well:\[code\]function convertGeneralAvailabilityTime($date,$from_timezone,$from_timebegin, $from_time${echo "$date,$from_timezone,$from_timebegin, $from_timeend, $to_timezone"; // 2010-09-19,America/New_York,07:45:00, 08:00:00, America/Los_Angeles$tz1 = new DateTimezone($from_timezone);$datetime1 = new DateTime("$date $from_timebegin", $tz1);$datetime2 = new DateTime("$date $from_timeend", $tz1);echo "$date $from_timebegin";// 2010-09-19 07:45:00echo "$date $from_timeend";// 2010-09-19 08:00:00var_export($tz1);//DateTimeZone::__set_state(array(//))var_export($datetime1);//DateTime::__set_state(array(//))\[/code\]SOmething is wrong with my php's DateTime() funciton - but I cannot fathom what! I'm using PHP 5.2.14 on this server.Edit 1: Sorry, misinterpreted some PHP output - corrected it aboveEdit 2: I had the following test file which gave the exactly output as below\[code\]<?php$date = '2010-09-19';$from_timezone = 'America/New_York';$from_timebegin = '07:45:00';$from_timeend = '08:00:00';$to_timezone = 'America/Los_Angeles'; // Trimmed 2010-09-19 07:45:002010-09-19$tz1 = new DateTimezone($from_timezone);$datetime1 = new DateTime("$date $from_timebegin", $tz1);$datetime2 = new DateTime("$date $from_timeend", $tz1);echo "$date $from_timebegin".PHP_EOL;echo "$date $from_timeend".PHP_EOL;var_dump($tz1);var_dump($datetime1);?>\[/code\]Output:\[code\]jailshell-3.2$ php dttest.php2010-09-19 07:45:002010-09-19 08:00:00object(DateTimeZone)#1 (0) {}object(DateTime)#2 (0) {}\[/code\]Edit 3 - if it helps, my phpinfo shows this as well\[code\]datedate/time support enabled"Olson" Timezone Database Version 2010.12Timezone Database externalDefault timezone America/Chicago \[/code\]
 
Back
Top