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? 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? 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 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. 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 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 Link to comment https://forums.phpfreaks.com/topic/206690-help-with-date/#findComment-1081039 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.