954,164 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

DateTime CLASS problem

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;
}
?>
kris82009
Newbie Poster
3 posts since May 2009
Reputation Points: 10
Solved Threads: 0
 

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.

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,755 posts since Oct 2006
Reputation Points: 1,168
Solved Threads: 1,074
 
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

kris82009
Newbie Poster
3 posts since May 2009
Reputation Points: 10
Solved Threads: 0
 

$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

kris82009
Newbie Poster
3 posts since May 2009
Reputation Points: 10
Solved Threads: 0
 

What is the error?

kkeith29
Nearly a Posting Virtuoso
1,353 posts since Jun 2007
Reputation Points: 235
Solved Threads: 195
 

are you just trying to 'correct' a server datetime to the user's local time?

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,755 posts since Oct 2006
Reputation Points: 1,168
Solved Threads: 1,074
 

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');
danishbacker
Junior Poster in Training
97 posts since Apr 2008
Reputation Points: 10
Solved Threads: 7
 

Also paste the code for "timezone.php"

danishbacker
Junior Poster in Training
97 posts since Apr 2008
Reputation Points: 10
Solved Threads: 7
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You