Re: convert w date to l format
| From: | Jochem Maas | Date: | Sat, 06 Jan 2007 13:21:46 +0000 |
| Subject: | Re: convert w date to l format | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-246682@lists.php.net to get a copy of this message | ||
Robert Cummings wrote:
> On Sat, 2007-01-06 at 14:46 +0200, 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
>>
>> I have tried $day = date('w', $day);
>>
>> But this does not seem to work ... can anyone assist?
>
> Something like:
>
> <?php
>
> $monday = strtotime( "next monday" );
> for( $i = 0; $i < 7; $i++ )
> {
> echo date( 'w', $monday + (24 * 60 * 60 * $i) )."\n";
> }
>
> ?>
let do a merge of Robbert and Stut ;-) a mindmeld of sorts.
<?php
$mon = strtotime('next monday');
$day = 4 * 60 * 60;
$days = array();
for ($i = 0; $i < 7; $i++)
$days[$i] = date('w', $mon + ($day * $i));
// now you have a localized array of day names, that you can
// use in your output [loop?] in the way that Stut described.
>
> Cheers,
> Rob.