PHP: How to get the days of the week?

Posted by fwaokda on Stack Overflow See other posts from Stack Overflow or by fwaokda
Published on 2011-01-03T21:50:01Z Indexed on 2011/01/03 21:53 UTC
Read the original article Hit count: 154

Filed under:
|
|

I'm wanting to store items in my database with a DATE value for a certain day. I don't know how to get the current Monday, or Tuesday, etc. from the current week. Here is my current database setup.

menuentry
 id int(10) PK
 menu_item_id int(10) FK
 day_of_week date
 message varchar(255)

So I have a class setup that holds all the info then I was going to do something like this...

foreach ( $menuEntryArray as $item )
{
   if ( $item->getDate() == [DONT KNOW WHAT TO PUT HERE] )
   {
      // code to display menu_item information
   }
} 

So I'm just unsure what to put in "[DONT KNOW WHAT TO PUT HERE]" to compare to see if the date is specified for this week's Monday, or Tuesday, etc. The foreach above runs for each day of the week - so it'll look like this...

Monday
Item 1
Item 2
Item 3

Tuesday
Item 1

Wednesday
Item 1
Item 2

...

Thanks!

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql