doforumda Posted July 4, 2010 Share Posted July 4, 2010 hi i get date of birth of db. now i want to split day month and year from that date and put them in different variables. e.g, $dob = $row['dob']; how would i do this? Quote Link to comment https://forums.phpfreaks.com/topic/206690-help-with-date/ Share on other sites More sharing options...
trq Posted July 4, 2010 Share Posted July 4, 2010 What does $row['dob'] look like? Quote Link to comment https://forums.phpfreaks.com/topic/206690-help-with-date/#findComment-1080972 Share on other sites More sharing options...
doforumda Posted July 4, 2010 Author Share Posted July 4, 2010 it looks like yyyy-mm-dd format Quote Link to comment https://forums.phpfreaks.com/topic/206690-help-with-date/#findComment-1080974 Share on other sites More sharing options...
trq Posted July 4, 2010 Share Posted July 4, 2010 Then take a look at strtotime and then date. Quote Link to comment https://forums.phpfreaks.com/topic/206690-help-with-date/#findComment-1080975 Share on other sites More sharing options...
kenrbnsn Posted July 4, 2010 Share Posted July 4, 2010 Why use those two functions when you can use explode? <?php list($year,$mon,$day) = explode('-',$row['dob']); ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/206690-help-with-date/#findComment-1081017 Share on other sites More sharing options...
Seaholme Posted July 4, 2010 Share Posted July 4, 2010 I think another option might be something like extracting a substring from the string you already have. You can see the command to do it on this page here, in the top table, 6th one down: http://www.redhat.com/docs/manuals/database/RHDB-7.1.3-Manual/sql/functions-string.html Quote Link to comment https://forums.phpfreaks.com/topic/206690-help-with-date/#findComment-1081039 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.