note 20269 modified in function.getdate by victor
| From: | victor@php.net | Date: | Sat, 24 Aug 2002 16:15:40 +0000 |
| Subject: | note 20269 modified in function.getdate by victor | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-35538@lists.php.net to get a copy of this message | ||
[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
--was--
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
http://www.php.net/manual/en/function.getdate.php