Destramic Posted October 10, 2011 Share Posted October 10, 2011 hey days im trying to get the differnce between the two dates but $start_date = new DateTime($start_date); $todays_date = new DateTime("now"); $interval = $start_date->diff($todays_date); echo $interval->format('%R%a days'); but the error im getting is Fatal error: Call to undefined method DateTime::diff() i dont see what im doing wrong if someone could help please thank you Quote Link to comment https://forums.phpfreaks.com/topic/248839-diffrence-between-two-dates/ Share on other sites More sharing options...
PFMaBiSmAd Posted October 10, 2011 Share Posted October 10, 2011 The method you are trying to use requires the latest php version - (PHP 5 >= 5.3.0) Quote Link to comment https://forums.phpfreaks.com/topic/248839-diffrence-between-two-dates/#findComment-1277892 Share on other sites More sharing options...
Destramic Posted October 10, 2011 Author Share Posted October 10, 2011 silly me...i best get with the times then...thank you Quote Link to comment https://forums.phpfreaks.com/topic/248839-diffrence-between-two-dates/#findComment-1277901 Share on other sites More sharing options...
Destramic Posted October 10, 2011 Author Share Posted October 10, 2011 ok all updated and these errors come up which i never seen before Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct() [<a href='datetime.--construct'>datetime.--construct</a>]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/London' for '1.0/DST' instead' in C:\www\private\application\controllers\tournaments_controller.class.php:30 Stack trace: #0 C:\www\private\application\controllers\tournaments_controller.class.php(30): DateTime->__construct('2011-10-06') #1 [internal function]: Tournaments_Controller->tournament('counter-strike', 'test') #2 C:\www\private\library\action\action.class.php(47): call_user_func_array(Array, Array) #3 C:\www\private\library\dispatcher\dispatcher.class.php(101): Action->dispatch('tournament', Array) #4 C:\www\private\library\front_controller\front_controller.class.php(132): in <b>C:\www\private\application\controllers\tournaments_controller.class.php</b> on line <b>30</b><br /> help please Quote Link to comment https://forums.phpfreaks.com/topic/248839-diffrence-between-two-dates/#findComment-1277915 Share on other sites More sharing options...
darkspire Posted October 10, 2011 Share Posted October 10, 2011 hmm not sure. this may help http://txt.binnyva.com/2007/03/find-difference-between-2-dates-in-php/ Quote Link to comment https://forums.phpfreaks.com/topic/248839-diffrence-between-two-dates/#findComment-1277924 Share on other sites More sharing options...
jcbones Posted October 10, 2011 Share Posted October 10, 2011 Yes, with the latest version, PHP wants you to specify the timezone with date_default_timezone_set. Quote Link to comment https://forums.phpfreaks.com/topic/248839-diffrence-between-two-dates/#findComment-1277938 Share on other sites More sharing options...
Destramic Posted October 10, 2011 Author Share Posted October 10, 2011 that worked a dream thanks jcbones Quote Link to comment https://forums.phpfreaks.com/topic/248839-diffrence-between-two-dates/#findComment-1277967 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.