Re: help with date formatting

From: Date: Wed, 06 Mar 2002 15:36:12 +0000
Subject: Re: help with date formatting
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-87476@lists.php.net to get a copy of this message
Sure, you could do something like: $event_month = substr($event_row["Date"], 5, 2); $event_day = substr($event_row["Date"], 8, 2); $event_year = substr($event_row["Date"], 0, 4); $msgBody = "Date: " . date("l", mktime(0,0,0,$event_month, $event_day, $event_year)) . ", " . date("F", mktime(0,0,0,$event_month, $event_day, $event_year)) . " " . fancyNumber((int) $event_day) . ", " . $event_year . "\n"; function fancyNumber($num) { // a better implementation should use '%'. if ($num < 1) return $num; else if ($num == 1 || $num == 21 || $num == 31) return $num . "st"; else if ($num == 2 || $num == 22) return $num . "nd"; else if ($num == 3 || $num == 23) return $num . "rd"; else return $num . "th"; } Sorry, I forgot to change my implementation to use %. But, you would get the idea... :) --- Ryan <SpanglerRP22@uww.edu> wrote: > Hi, I'm trying to create an events page, where it > shows the posted > events. I enter data using phpmyadmin. Currently, > the ouput is like > this: > > -------------------------------------------------------- > Conference in New York > 2002-03-06 > > There is going to be a conference in New York next > week. > -------------------------------------------------------- > > I'm having trouble with the formatting of the date. > I'm using the type > date with the function now, so it shows the current > date when I post an > event. Here is what I would like: > > -------------------------------------------------------- > Conference in New York > Wednesday, March 5th, 2002 > > There is going to be a conference in New York next > week. > -------------------------------------------------------- > > Thanks for any help. > > -- > Ryan Spangler > 428 N Harmony Ln, Apt. 3 > Whitewater, WI 53190 > (262) 473-8392 > SpanglerRP22@uww.edu > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > ===== Anas Mughal anasmughal@yahoo.com anasmughal@hotmail.com Tel: 973-249-6665 __________________________________________________ Do You Yahoo!? Try FREE Yahoo! Mail - the world's greatest free email! http://mail.yahoo.com/

« previous php.general (#87476) next »