Woodburn2006 Posted September 11, 2007 Share Posted September 11, 2007 if i have a date stored in my DB as 11/09/2007 is there anyway i can change it to 11th Sep once i have pulled it from the DB? Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 11, 2007 Share Posted September 11, 2007 You'll need to use date() and strtotime() Quote Link to comment Share on other sites More sharing options...
Woodburn2006 Posted September 11, 2007 Author Share Posted September 11, 2007 i tried: $date = 11/09/2007; $date = date('jS M', $date); and for some reason it came out as '31st Dec' which is the right format but wrong date Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 11, 2007 Share Posted September 11, 2007 You only used one of the functions I said. Quote Link to comment Share on other sites More sharing options...
Woodburn2006 Posted September 11, 2007 Author Share Posted September 11, 2007 ok cool, my mistake $date = 11/09/2007; $date = strtotime("$date"); $date = date('jS M', $date); that works fine except the fact that it is reading it as an american date, but it is in a british date so it is reading it as if its 9th Nov instead of 11th Sep Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 11, 2007 Share Posted September 11, 2007 Ah. Well if you know it will always be the british date, you could use substr() to take the day and month numbers and switch them. If you can't figure out how to do that post again and I'll post it for you. Quote Link to comment Share on other sites More sharing options...
Woodburn2006 Posted September 11, 2007 Author Share Posted September 11, 2007 ah sweet, i done it. used this: $day = substr("$date", 0, -; $month = substr("$date", 3, -5); $year = substr ("$date", -4); $date = "$month/$day/$year"; $date = strtotime("$date"); $date = date('jS M', $date); dont know if thats the long way round but it works? thanks Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 11, 2007 Share Posted September 11, 2007 That's how I'd do it. Quote Link to comment Share on other sites More sharing options...
Dragen Posted September 11, 2007 Share Posted September 11, 2007 wouldn't this be easier: list($d, $m, $y) = explode('/', $date); $date = strtotime("$m/$d/$y"); $date = date('jS M', $date); Just a bit shorter, but should work as well Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 11, 2007 Share Posted September 11, 2007 Great idea Dragen. Quote Link to comment Share on other sites More sharing options...
Woodburn2006 Posted September 11, 2007 Author Share Posted September 11, 2007 ideal, thanks alot Quote Link to comment Share on other sites More sharing options...
Dragen Posted September 11, 2007 Share Posted September 11, 2007 no problem Quote Link to comment 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.