cobusbo Posted September 24, 2015 Share Posted September 24, 2015 Hi I'm currently using a header to retrieve some info $prof = $_SERVER["HTTP_X_MXIT_PROFILE"]; It output the value as en,ZA,1991-01-30,Male,1 I'm trying to use the 1991-01-30 from the above output to calculate if the person is 18 years of age or older Any suggestions on how to do this I tried to put it into an array but was unsuccessful... Quote Link to comment https://forums.phpfreaks.com/topic/298299-string-to-array-and-date/ Share on other sites More sharing options...
Solution Barand Posted September 24, 2015 Solution Share Posted September 24, 2015 try $str = "en,ZA,1991-01-30,Male,1"; $items = explode(',', $str); $date = new DateTime($items[2]); $age = $date->diff(new DateTime())->y; echo $age; 1 Quote Link to comment https://forums.phpfreaks.com/topic/298299-string-to-array-and-date/#findComment-1521469 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.