kernelgpf Posted July 26, 2008 Share Posted July 26, 2008 I'm trying to get the English ordinal suffix for the day of the month (the "th", "nd", etc.) like 1st, 2nd, 3rd, 4th, etc. To format TODAY'S date, I know you do.. $day3=date('S'); But how do I figure out another date's "S"? I have a string named $day, and I need to figure out it's "S", if that makes sense. Thanks! Link to comment https://forums.phpfreaks.com/topic/116746-solved-formatting-a-date-other-than-todays/ Share on other sites More sharing options...
DarkWater Posted July 26, 2008 Share Posted July 26, 2008 Use mktime() to get the timestamp for the date and use it as the second parameter to the date() function. Link to comment https://forums.phpfreaks.com/topic/116746-solved-formatting-a-date-other-than-todays/#findComment-600364 Share on other sites More sharing options...
wildteen88 Posted July 26, 2008 Share Posted July 26, 2008 Alternatively Convert the the date to a unix timestamp (using strtotime()), then use date() like so: $date = '12/09/2008'; $utime = strtotime($date); echo date('S', $utime); Link to comment https://forums.phpfreaks.com/topic/116746-solved-formatting-a-date-other-than-todays/#findComment-600366 Share on other sites More sharing options...
DarkWater Posted July 26, 2008 Share Posted July 26, 2008 Either works. I wasn't sure how he had the date stored. Link to comment https://forums.phpfreaks.com/topic/116746-solved-formatting-a-date-other-than-todays/#findComment-600368 Share on other sites More sharing options...
kernelgpf Posted July 26, 2008 Author Share Posted July 26, 2008 It worked. Thanks guys! I'm a girl. Link to comment https://forums.phpfreaks.com/topic/116746-solved-formatting-a-date-other-than-todays/#findComment-600400 Share on other sites More sharing options...
DarkWater Posted July 26, 2008 Share Posted July 26, 2008 I wasn't sure how she had the date stored. =P Sorry. Link to comment https://forums.phpfreaks.com/topic/116746-solved-formatting-a-date-other-than-todays/#findComment-600488 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.