Re: Reverse of date("w")

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Another way to do it would be to store the unix epoch and then just get the
weekday name from that?  More overhead than Travis's idea, but just as good
and you could possibly use the date/time later on.

On 9/18/06, Travis Doherty <travis@xxxxxxxxxxxxx> wrote:

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;

}
?>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux