brown2005 Posted September 18, 2006 Share Posted September 18, 2006 if i have$a = $array['date'];and $a is now 2006-05-01how do i turn that into the 1st.please dont say look at the date() function because it doesnt explain it there...thanks very much...p.s. i now its something like date('d', $a); or something like that... but dont u need to string it or somethin..... Quote Link to comment Share on other sites More sharing options...
obsidian Posted September 18, 2006 Share Posted September 18, 2006 very close... i'd recommend something like this:[code]<?phpfunction dateSuffix($date) { $day = substr(date('d', strtotime($date)), -1); switch ($day) { case 1: $day .= 'st'; break; case 2: $day .= 'nd'; break; case 3: $day .= 'rd'; break; default: $day .= 'th'; } return $day;}echo dateSuffix('2006-05-01');?>[/code]hope this helps Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted September 18, 2006 Share Posted September 18, 2006 [quote]please dont say look at the date() function because it doesnt explain it there...[/quote]Have you looked recently? Use the 'S' format character:[code]<?phpecho date ('F jS',strtotime('2006-05-01'));?>[/code]Ken Quote Link to comment Share on other sites More sharing options...
obsidian Posted September 19, 2006 Share Posted September 19, 2006 [quote author=kenrbnsn link=topic=108537.msg436767#msg436767 date=1158610822][quote]please dont say look at the date() function because it doesnt explain it there...[/quote]Have you looked recently? Use the 'S' format character:[code]<?phpecho date ('F jS',strtotime('2006-05-01'));?>[/code]lol... no freaking way! i have used that 'S' modifier in many scripts, and i completely forgot about it when answering that post... thanks ken :PKen[/quote] 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.