| | |
DateTime CLASS problem
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: May 2009
Posts: 3
Reputation:
Solved Threads: 0
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:
--------------------------------------------------------------------------------------------------------
CODE:
--------------------------------------------------------------------------------------------------------
php Syntax (Toggle Plain Text)
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; } ?>
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.
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.
If you don't reply to your own thread or you can't find the solved link - you're off my Christmas list - permanently! Bah humbug!
Are you getting any error or incorrect date?
if it is incorrect date then setting the default timezone as below will solve ur problem
if it is incorrect date then setting the default timezone as below will solve ur problem
PHP Syntax (Toggle Plain Text)
date_default_timezone_set('Asia/Calcutta');
![]() |
Similar Threads
- Fraction Class problem (C++)
- Class array inside of a class array inside of a class problem (C++)
- String/Class problem(s)!! (C++)
- Descending timer problem (C#)
- Programming VBA Dynamic Arry of Custom Class Problem (Visual Basic 4 / 5 / 6)
- Need help with a class problem. (Python)
- Query class problem (PHP)
- Abstract class homework problem (C++)
- gtk.ListStore / gtk.ComboBoxEntry class problem (Python)
Other Threads in the PHP Forum
- Previous Thread: How to implement check availability in hotel reservation system
- Next Thread: admin
Views: 686 | Replies: 7
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery js limit link login loop mail mediawiki menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search select server sessions sms soap source space speed sql stored structure subdomain syntax system table tutorial update updates upload url validation validator variable video web xml youtube






