richiec Posted July 13, 2009 Share Posted July 13, 2009 In my DB i have a date layed out like (July 12th, 2009, 6:43 pm) for each entry for when it was done. Its used for a few pages but on one of the pages i need it to be a shorter version of that date but ive hit a road block because now it just echos back Dec 31st 69 this is what i did: $datedone = mysql_result($result,$i,"date"); $newdate = date("M jS y", $datedone); Any idea where im going wrong? Thanks Rich Quote Link to comment https://forums.phpfreaks.com/topic/165830-solved-date-problem/ Share on other sites More sharing options...
wildteen88 Posted July 13, 2009 Share Posted July 13, 2009 date expects a unix timestamp. You need to do $newdate = date("M jS y", strtotime($datedone)); Quote Link to comment https://forums.phpfreaks.com/topic/165830-solved-date-problem/#findComment-874683 Share on other sites More sharing options...
.josh Posted July 13, 2009 Share Posted July 13, 2009 date expects a timestamp for the 2nd argument. So you would need to strtotime $datedone, before using it in date(). But you can skip all that and reformat it in your query. Quote Link to comment https://forums.phpfreaks.com/topic/165830-solved-date-problem/#findComment-874685 Share on other sites More sharing options...
richiec Posted July 13, 2009 Author Share Posted July 13, 2009 Thanks, got it working now =) I did have to add one more thing though before it would work: $datedone = mysql_result($result,$i,"date"); $newd = str_replace(",","",$datedone ); $newdate = date("M jS", strtotime($newd)); I guess because i was no longer using , in the new date it was getting confused. But its working now so thanks again for the help <3 Quote Link to comment https://forums.phpfreaks.com/topic/165830-solved-date-problem/#findComment-874690 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.