RE: [PHP] Working out the name of the day given a date

2001-01-16 Thread Jon Haworth

Gah. I read that lower case l as a number 1. Time to get new glasses/switch
to 640x480 mode.

Thanks to everyone for your help.


Cheers
Jon


-Original Message-
From: Andrew Rush [mailto:[EMAIL PROTECTED]]
Sent: 16 January 2001 16:03
To: Jon Haworth
Subject: Re: [PHP] Working out the name of the day given a date



On Tuesday, January 16, 2001, at 10:56 AM, Jon Haworth wrote:

> Just a quickie. Does anyone have a code snippet for calculating the day of

> the week given a date? I was hoping I could feed a string like "20010116"
to 
> a function and have it return "Tuesday" - it doesn't have to be exactly
this 
> date format that is used for the input, but I do need the name of the day
on 
> the output! 

covert your date string to a unix timestamp and then use date("l",
$myString)
have a great day,
andy

:: Andrew Rush :: Lead Systems Developer :: MaineToday.com ::
**
"Crippled but free, blind all the time, i was learning to see"

- J. Garcia / R. Hunter
**

The  views expressed herein are not necessarily those of my employer, but
they let me have them anyway.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Working out the name of the day given a date

2001-01-16 Thread Ignacio Vazquez-Abrams

On Tue, 16 Jan 2001, Jon Haworth wrote:

> Hmmm. I did:
>
>   $timestamp = mktime(0,0,0,$month,$date,$year);
>   $day = date("1", $timestamp);
>
> and it returns 1, no matter what the contents of $month, $date and $year
> are. Did I miss something?
>

Yes, you're missing the fact that it's a lowercase 'L', and not in fact the
numeral '1'.

-- 
Ignacio Vazquez-Abrams  <[EMAIL PROTECTED]>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Working out the name of the day given a date

2001-01-16 Thread Jon Haworth

Hmmm. I did:

$timestamp = mktime(0,0,0,$month,$date,$year);
$day = date("1", $timestamp);

and it returns 1, no matter what the contents of $month, $date and $year
are. Did I miss something?



-Original Message-
From: Andrew Rush [mailto:[EMAIL PROTECTED]]
Sent: 16 January 2001 16:03
To: Jon Haworth
Subject: Re: [PHP] Working out the name of the day given a date



On Tuesday, January 16, 2001, at 10:56 AM, Jon Haworth wrote:

> Just a quickie. Does anyone have a code snippet for calculating the day of

> the week given a date? I was hoping I could feed a string like "20010116"
to 
> a function and have it return "Tuesday" - it doesn't have to be exactly
this 
> date format that is used for the input, but I do need the name of the day
on 
> the output! 

covert your date string to a unix timestamp and then use date("l",
$myString)
have a great day,
andy

:: Andrew Rush :: Lead Systems Developer :: MaineToday.com ::
**
"Crippled but free, blind all the time, i was learning to see"

- J. Garcia / R. Hunter
**

The  views expressed herein are not necessarily those of my employer, but
they let me have them anyway.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Working out the name of the day given a date

2001-01-16 Thread Ignacio Vazquez-Abrams

On Tue, 16 Jan 2001, Jon Haworth wrote:

> Hello list,
>
> Just a quickie. Does anyone have a code snippet for calculating the day of
> the week given a date? I was hoping I could feed a string like "20010116" to
> a function and have it return "Tuesday" - it doesn't have to be exactly this
> date format that is used for the input, but I do need the name of the day on
> the output!
>
> I'm hunting around at the moment but I haven't had any joy so far, I thought
> I'd see if anyone's already invented this wheel...
>
> Cheers
> Jon
>

Try date('l'). (lowercase L)

-- 
Ignacio Vazquez-Abrams  <[EMAIL PROTECTED]>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Working out the name of the day given a date

2001-01-16 Thread Jon Haworth

Cheers Andy, between my last post and this one I came up with a rather
long-winded way of doing it...

$dayarray = getdate(mktime(0,0,0,$month,$date,$year));
switch ($dayarray["wday"]) {
case 0:
$day = "Sunday";
break;
case 1: 
$day = "Monday";
break;
case 2: 
$day = "Tuesday";
break;
case 3: 
$day = "Wednesday";
break;
case 4: 
$day = "Thursday";
break;
case 5: 
$day = "Friday";
break;
case 6: 
$day = "Saturday";
break;
}

Ugh. I'll try your method.

Cheers
Jon


-Original Message-
From: Andrew Rush [mailto:[EMAIL PROTECTED]]
Sent: 16 January 2001 16:03
To: Jon Haworth
Subject: Re: [PHP] Working out the name of the day given a date



On Tuesday, January 16, 2001, at 10:56 AM, Jon Haworth wrote:

> Just a quickie. Does anyone have a code snippet for calculating the day of

> the week given a date? I was hoping I could feed a string like "20010116"
to 
> a function and have it return "Tuesday" - it doesn't have to be exactly
this 
> date format that is used for the input, but I do need the name of the day
on 
> the output! 

covert your date string to a unix timestamp and then use date("l",
$myString)
have a great day,
andy

:: Andrew Rush :: Lead Systems Developer :: MaineToday.com ::
**
"Crippled but free, blind all the time, i was learning to see"

- J. Garcia / R. Hunter
**

The  views expressed herein are not necessarily those of my employer, but
they let me have them anyway.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]