Re: Reverse of date("w")
| From: | Travis Doherty | Date: | Tue, 19 Sep 2006 00:15:28 +0000 |
| Subject: | Re: Reverse of date("w") | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-241914@lists.php.net to get a copy of this message | ||
Kevin Murphy wrote:
> Not really. If it were always "today" that would work, but in this
> case, I was thinking of storing a day of the week in a database
> ("3"), and then display the info based on that digit. So assuming
> that the number was in fact 3, then:
>
> echo date("D","3");
>
> Would return "Wed".
>
> Is there any function like that? Oh, and it has to run on PHP 4.
>
Any reason you wouldn't write it yourself?
<?php
function getDayFromInteger($integer)
{
$days =
array('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
if (isset($days[$integer]))
{
return $days[$integer];
}
return false;
}
?>