vicodin Posted November 29, 2008 Share Posted November 29, 2008 Hello all... I am going to have the following format of time in my db. I would like to just be able to get the time out of it... How would i do that? Date Format: 2008/08/27 Link to comment https://forums.phpfreaks.com/topic/134711-comparing-just-the-year-in-the-date/ Share on other sites More sharing options...
dezkit Posted November 29, 2008 Share Posted November 29, 2008 ... So you are trying to get the time out of a date, isn't that like making a bottle of pepsi appear out of nowhere? Link to comment https://forums.phpfreaks.com/topic/134711-comparing-just-the-year-in-the-date/#findComment-701435 Share on other sites More sharing options...
vicodin Posted November 29, 2008 Author Share Posted November 29, 2008 lol sorry i meant i just want the 2008 out of the 2008/08/27 ... Link to comment https://forums.phpfreaks.com/topic/134711-comparing-just-the-year-in-the-date/#findComment-701439 Share on other sites More sharing options...
dezkit Posted November 29, 2008 Share Posted November 29, 2008 <?php $date = "2008/08/27"; $pieces = explode("/", $date); echo $pieces[0]; ?> Link to comment https://forums.phpfreaks.com/topic/134711-comparing-just-the-year-in-the-date/#findComment-701444 Share on other sites More sharing options...
vicodin Posted November 29, 2008 Author Share Posted November 29, 2008 i went this way... $date = "2008/08/28"; $date = substr($date,0,4); thanks for the reply though. Link to comment https://forums.phpfreaks.com/topic/134711-comparing-just-the-year-in-the-date/#findComment-701453 Share on other sites More sharing options...
kenrbnsn Posted November 29, 2008 Share Posted November 29, 2008 It would be much simpler to store the date in a "DATE" field with the format YYYY-MM-DD, then you can use the MySQL routines to return just the year. Ken Link to comment https://forums.phpfreaks.com/topic/134711-comparing-just-the-year-in-the-date/#findComment-701493 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.