Hi guys, Ok,im new to functions and yet trying getting my head around them. Why does this code work : <?php $start_date = '2010-02-27 11:50'; $end_date = '2010-03-05 11:50'; $seconds = strtotime($end_date) - strtotime($start_date); $days = floor($seconds / 86400); echo "The difference is {$days} days.<br>"; ?> Code (markup): and this function doesnt ? <?php function getDays($start_dat,$end_date) { $seconds = strtotime($end_date) - strtotime($start_date); $days = floor($seconds / 86400); return $days; } $start_date = '2010-02-27 11:50'; $end_date = '2010-02-28 11:50'; echo getDays($start_date,$end_date); ?> Code (markup): Any comments are welcome
When posting questions specific to code not working always post any errors you get and/or actual results vs. expected results. For your specific issue, you forgot the 'e' on $start_date when you declared the function: function getDays($start_dat,$end_date)
oh my,thank you, i guess i should go and get some sleep regarding code questions, i will have that in mind !