We were working on a recent project where we had to figure out what day of the week it was and present something on the frontend of the website specifically for each day. The conditional script could be used to change any aspect of a website design based on the day of the week.

It is important to change the settings in WordPress under “Settings” > “General” and next to “Timezone” to be accurate to the timezone of your website. Once you do this, and use the code below, the script will accurately display or do whatever you echo in the php script. You can of course also use a php switch for this if you like.

Note about the timezone : we set the timezone directly in the script because working with server times and the WordPress timezone setting can be a little weird we’ve found, so it’s best to set the timezone directly.