Problems? Solutions...
Problems
Jun 18th, 2009
Day 1 is always a Monday. Given day n days after day 1, find the week day of n without using date functions.
<?php
$n = 111;
$days = array( "Mon", "Tues", "Wed", "Thurs", "Fri", "Sat", "Sun" );
$day = days[$n%7];
echo "$n ( $day )";
?>
This was for a client with a lesson subscription program. The subscription type has a 180 day ( 6-mo ) sequence of dates always starting from the Monday previous to your purchase date. All the lessons are meant to be on specific weekdays. Similar code to this was placed in the dropdowns for sequence selection and the list of lessons in order to make it quick and easy to tell what integer you were aiming for when adding / editing a lesson.