wattsup88 Posted January 6, 2007 Share Posted January 6, 2007 I have a date that i need to work with, but in my database it is entered like 2006-03-07... i need to know how to "cut" all of the hyphens out of the date returned by the database... that way i can write a script to delete all of the rows with an expired date... Thanks,Jacob Link to comment https://forums.phpfreaks.com/topic/33103-solved-cutting-strings/ Share on other sites More sharing options...
paul2463 Posted January 6, 2007 Share Posted January 6, 2007 try using <a href="http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html">DATE_FORMAT()</a> you can the format the date exactly as you want it when you pull it from the database. Link to comment https://forums.phpfreaks.com/topic/33103-solved-cutting-strings/#findComment-154237 Share on other sites More sharing options...
taith Posted January 6, 2007 Share Posted January 6, 2007 $date='2006-03-07';$date=str_replace("-", "", "$date");echo $date; #20060307edit: just as a note its MUCH easier to have date(z) in the database, expire, remove that way... ;-) Link to comment https://forums.phpfreaks.com/topic/33103-solved-cutting-strings/#findComment-154241 Share on other sites More sharing options...
wattsup88 Posted January 6, 2007 Author Share Posted January 6, 2007 Thanks so much guys oh and just so you know taith I won't be using the database I'm creating it for someone else... I of course want it to be user friendly, and I don't always have the knowledge to make it user friendly and practical. So I figured this would be the best way... again thanks for the help... Link to comment https://forums.phpfreaks.com/topic/33103-solved-cutting-strings/#findComment-154250 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.