note 20269 deleted from function.getdate by tomsommer

From: Date: Wed, 15 Sep 2004 16:38:04 +0000
Subject: note 20269 deleted from function.getdate by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-76756@lists.php.net to get a copy of this message
Note Submitter: petercawley at hotmail dot com ---- [Editor's note: To avoid re-inventing the wheel, use: $dat = date('l \t\h\e Js \o\f F Y'); ] Heres a little bit of code to create a posh date : <?php $today = getdate(); $mon = $today['month']; $day = $today['weekday']; $dayn = $today['mday']; $year = $today['year']; if ($dayn == 1) { $ex = "st"; } elseif ($dayn == 2) { $ex = "nd"; } elseif ($dayn == 3) { $ex = "rd"; } elseif ($dayn == 21) { $ex = "st"; } elseif ($dayn == 22) { $ex = "nd"; } elseif ($dayn == 23) { $ex = "rd"; } elseif ($dayn == 31) { $ex = "st"; } elseif ($dayn == 32) { $ex = "nd"; } else { $ex = "th"; } $dat = sprintf("%s the %s%s of %s %s",$day,$dayn,$ex,$mon,$year); ?> $dat would be something like this: Thursday the 28th of March 2002

« previous php.notes (#76756) next »