Forum Moderators: coopster

Message Too Old, No Replies

Quick PHP date() question

         

DrDoc

5:12 pm on Apr 10, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I just want to know if this would work:

date("l","21-10-2003")

Would that give me the day of the week? I'm not where I can test it myself right now, so I just need to know if that kind of syntax would work... or do I need to convert the date to a real timestamp? (The server is a Linux machine)

<added>The first string is a lowercase L</added>

mavherick

5:30 pm on Apr 10, 2003 (gmt 0)

10+ Year Member



Yes it works, outputted "Wednesday" in this case.

(Also on Linux)

mavherick

Paul in South Africa

5:38 pm on Apr 10, 2003 (gmt 0)

10+ Year Member



I don't know if I have been looking at a screen for to long today, but 21 Oct 2003 is a Tuesday in my calendar.

DrDoc

5:52 pm on Apr 10, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yep, it's a Tuesday. So... :)

mavherick

5:53 pm on Apr 10, 2003 (gmt 0)

10+ Year Member



Woah! Good point Paul, After further testing, this won't work at all! (I guess Wednesday is the default value in case it can't figure it out)

So yes, you'll have to convert it back to a timestamp like this

date("l", mktime(0,0,0,10,21,2003))

sorry about that

mavherick

DrDoc

5:56 pm on Apr 10, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I was able to test it now myself... and I'm afraid it doesn't work :(

10-10-2002 Wednesday
01-01-2003 Wednesday
15-05-2003 Wednesday
21-10-2003 Wednesday

DrDoc

6:00 pm on Apr 10, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yep, that works great! :)

10-10-2002 Thursday
01-01-2003 Wednesday
15-05-2003 Thursday
21-10-2003 Tuesday