DateTime CLASS problem

Reply

Join Date: May 2009
Posts: 3
Reputation: kris82009 is an unknown quantity at this point 
Solved Threads: 0
kris82009 kris82009 is offline Offline
Newbie Poster

DateTime CLASS problem

 
0
  #1
May 22nd, 2009
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:
--------------------------------------------------------------------------------------------------------
  1. function trackCountry($ip,$date)
  2. {
  3. include("geoip.inc");
  4. include("geoipcity.inc");
  5. include("geoipregionvars.php");
  6. //function for opening the database
  7. $gi = geoip_open("/opt/lampp/htdocs/theopencamp/Ver2/theopencamp2/include/GeoLiteCity.dat", GEOIP_STANDARD);
  8. //function to retrieve the information of the particular ip and casting it to array
  9. $rsGeoData =(array) geoip_record_by_addr($gi,$ip);
  10. geoip_close($gi);
  11. if(is_array($rsGeoData))
  12. {
  13. $countrycode=$rsGeoData['country_code'];
  14. $region=$rsGeoData['region'];
  15. }
  16. //Converting of localtime to utc
  17. require("timezone.php");
  18. $tz= get_time_zone($countrycode,$region);
  19. $timestamp = 1240349566;
  20. // set this to the time zone provided by the user
  21. // create the DateTimeZone object for later
  22. $dtzone = new DateTimeZone($tz);
  23. // first convert the timestamp into a string representing the local time
  24. $time = date('r', $timestamp);
  25. // now create the DateTime object for this time
  26. $dtime = new DateTime($date);
  27. // convert this to the user's timezone using the DateTimeZone object
  28. $dtime->setTimeZone($dtzone);
  29. // print the time using your preferred format
  30. $time = $dtime->format('Y-m-d-H-i-s');
  31. return $time;
  32. }
  33. ?>
Last edited by peter_budo; May 22nd, 2009 at 4:03 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 1,066
Reputation: ardav will become famous soon enough ardav will become famous soon enough 
Solved Threads: 136
ardav's Avatar
ardav ardav is offline Offline
Veteran Poster

Re: DateTime CLASS problem

 
0
  #2
May 22nd, 2009
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.
Happy Humbugging Christmas
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 3
Reputation: kris82009 is an unknown quantity at this point 
Solved Threads: 0
kris82009 kris82009 is offline Offline
Newbie Poster

Re: DateTime CLASS problem

 
0
  #3
May 22nd, 2009
Originally Posted by ardav View Post
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
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 3
Reputation: kris82009 is an unknown quantity at this point 
Solved Threads: 0
kris82009 kris82009 is offline Offline
Newbie Poster

Re: DateTime CLASS problem

 
0
  #4
May 22nd, 2009
$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
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,227
Reputation: kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about 
Solved Threads: 167
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Nearly a Posting Virtuoso

Re: DateTime CLASS problem

 
0
  #5
May 22nd, 2009
What is the error?
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 1,066
Reputation: ardav will become famous soon enough ardav will become famous soon enough 
Solved Threads: 136
ardav's Avatar
ardav ardav is offline Offline
Veteran Poster

Re: DateTime CLASS problem

 
0
  #6
May 23rd, 2009
are you just trying to 'correct' a server datetime to the user's local time?
Happy Humbugging Christmas
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 75
Reputation: danishbacker is an unknown quantity at this point 
Solved Threads: 5
danishbacker's Avatar
danishbacker danishbacker is offline Offline
Junior Poster in Training

Re: DateTime CLASS problem

 
0
  #7
May 25th, 2009
Are you getting any error or incorrect date?
if it is incorrect date then setting the default timezone as below will solve ur problem
  1. date_default_timezone_set('Asia/Calcutta');
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 75
Reputation: danishbacker is an unknown quantity at this point 
Solved Threads: 5
danishbacker's Avatar
danishbacker danishbacker is offline Offline
Junior Poster in Training

Re: DateTime CLASS problem

 
0
  #8
May 25th, 2009
Also paste the code for "timezone.php"
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC