Hi Everybody ,i have a problem with DateTime class,I am using DateTime class in my program it works fine in php 5.2.6 .but the version in my server is php 5.1.6 so is there any class to replace the same functionality.please check the code below and if u find any solution for this please reply me.

CODE:
--------------------------------------------------------------------------------------------------------

function trackCountry($ip,$date)
{
include("geoip.inc");
include("geoipcity.inc");
include("geoipregionvars.php");
//function for opening the database 
$gi = geoip_open("/opt/lampp/htdocs/theopencamp/Ver2/theopencamp2/include/GeoLiteCity.dat", GEOIP_STANDARD);
//function to retrieve the information of the particular ip and casting it to array
$rsGeoData =(array) geoip_record_by_addr($gi,$ip);
geoip_close($gi);
         if(is_array($rsGeoData))
             {
               $countrycode=$rsGeoData['country_code'];
               $region=$rsGeoData['region'];
             }
             //Converting of localtime to utc
require("timezone.php");
$tz= get_time_zone($countrycode,$region);
$timestamp = 1240349566;
 // set this to the time zone provided by the user
 // create the DateTimeZone object for later
$dtzone = new DateTimeZone($tz);
 // first convert the timestamp into a string representing the local time
$time = date('r', $timestamp);
 // now create the DateTime object for this time
$dtime = new DateTime($date);
 // convert this to the user's timezone using the DateTimeZone object
$dtime->setTimeZone($dtzone);
// print the time using your preferred format
$time = $dtime->format('Y-m-d-H-i-s');
return $time;
}
?>

which part is causing the problem? Isolate the steps and echo or print out the variables. You need to know which elements are causing problems before you start making wholesale changes.

which part is causing the problem? Isolate the steps and echo or print out the variables. You need to know which elements are causing problems before you start making wholesale changes.

the DateTime function is throwing an error

$dtzone = new DateTimeZone($tz); is throwing error and this class does'nt support in php5.1.6 version so is there any replacement for that class

Are you getting any error or incorrect date?
if it is incorrect date then setting the default timezone as below will solve ur problem

date_default_timezone_set('Asia/Calcutta');
This article has been dead for over six months. Start a new discussion instead.