943,899 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1819
  • PHP RSS
May 22nd, 2009
0

DateTime CLASS problem

Expand Post »
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:
--------------------------------------------------------------------------------------------------------
php Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kris82009 is offline Offline
3 posts
since May 2009
May 22nd, 2009
0

Re: DateTime CLASS problem

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.
Sponsor
Featured Poster
Reputation Points: 1048
Solved Threads: 948
Sarcastic Poster
ardav is offline Offline
6,697 posts
since Oct 2006
May 22nd, 2009
0

Re: DateTime CLASS problem

Click to Expand / Collapse  Quote originally posted by ardav ...
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kris82009 is offline Offline
3 posts
since May 2009
May 22nd, 2009
0

Re: DateTime CLASS problem

$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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kris82009 is offline Offline
3 posts
since May 2009
May 22nd, 2009
0

Re: DateTime CLASS problem

What is the error?
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
May 23rd, 2009
0

Re: DateTime CLASS problem

are you just trying to 'correct' a server datetime to the user's local time?
Sponsor
Featured Poster
Reputation Points: 1048
Solved Threads: 948
Sarcastic Poster
ardav is offline Offline
6,697 posts
since Oct 2006
May 25th, 2009
0

Re: DateTime CLASS problem

Are you getting any error or incorrect date?
if it is incorrect date then setting the default timezone as below will solve ur problem
PHP Syntax (Toggle Plain Text)
  1. date_default_timezone_set('Asia/Calcutta');
Reputation Points: 10
Solved Threads: 7
Junior Poster in Training
danishbacker is offline Offline
97 posts
since Apr 2008
May 25th, 2009
0

Re: DateTime CLASS problem

Also paste the code for "timezone.php"
Reputation Points: 10
Solved Threads: 7
Junior Poster in Training
danishbacker is offline Offline
97 posts
since Apr 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: if statement /mysql help please
Next Thread in PHP Forum Timeline: admin





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC