Re: convert w date to l format
| From: | Robert Cummings | Date: | Sat, 06 Jan 2007 13:03:36 +0000 |
| Subject: | Re: convert w date to l format | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-246681@lists.php.net to get a copy of this message | ||
On Sat, 2007-01-06 at 12:59 +0000, Stut wrote:
> Steven Macintyre wrote:
> > Um ... can anyone point me to somewhere that it explains this ...
> >
> > I am trying to convert a "int" (1 through 7) to a day name (Monday through
> > Friday) while in a loop with mysql results
>
> What happened to the weekend? I'd hate to lose the weekend!!
>
> > I have tried $day = date('w', $day);
> >
> > But this does not seem to work ... can anyone assist?
>
> That's because the date function expects a timestamp.
>
> What you want is an array, nothing more complicated than that.
>
> $days = array(1 => 'Monday',
> 2 => 'Tuesday',
> 3 => 'Wednesday',
> 4 => 'Thursday',
> 5 => 'Friday',
> 6 => 'Saturday',
> 7 => 'Sunday');
>
> $day = $days[$day];
That's not locale portable :B
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com
|
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'