steviez Posted June 18, 2009 Share Posted June 18, 2009 Hi, In my database users dates of birth are stored like: 09/12/1986 Ho can I split the DOB up so I can get the day month and year separately? Thanks Link to comment https://forums.phpfreaks.com/topic/162823-solved-split-date-of-birth/ Share on other sites More sharing options...
MatthewJ Posted June 18, 2009 Share Posted June 18, 2009 $parts = explode("/", $dateofbirth); Link to comment https://forums.phpfreaks.com/topic/162823-solved-split-date-of-birth/#findComment-859206 Share on other sites More sharing options...
ldougherty Posted June 18, 2009 Share Posted June 18, 2009 or you could use substr $month = substr("$dateofbirth", 0, 2); $day = substr("$dateofbirth", 3, 2); $year = substr("$dateofbirth", 6, 4); Link to comment https://forums.phpfreaks.com/topic/162823-solved-split-date-of-birth/#findComment-859210 Share on other sites More sharing options...
steviez Posted June 18, 2009 Author Share Posted June 18, 2009 $parts = explode("/", $dateofbirth); I have done this: $parts = explode("/", $dateofbirth); $parts[0] // day $parts[1] // month $parts[2] // year is that OK? Link to comment https://forums.phpfreaks.com/topic/162823-solved-split-date-of-birth/#findComment-859213 Share on other sites More sharing options...
MatthewJ Posted June 19, 2009 Share Posted June 19, 2009 yup Link to comment https://forums.phpfreaks.com/topic/162823-solved-split-date-of-birth/#findComment-859407 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.