Hi all,
I'm having lots of trouble with the date/time functions of php at the minute.
i have a set of reviews each written for a particular month. I already have a page in which the user can see all the reviews written during the current month. Now i want to add a bit more usablity and allow the user to click through the previous months and see the reviews of that month.
the way my code works at the moment is a variable called $startOfMonth which takes the first day of the current month and another variable called $endOfMonth which takes the last day of the current month.
I had to get some help setting these variables but heres what i ended up with (I appreciate it looks a bit random)
$startOfMonth = date("Y",mktime(0,0,0,date("n"),1,date("Y")))."-".date("m",mktime(0,0,0,date("n"),1,date("Y")))."-".date("d",mktime
$endOfMonth = date("Y")."-".date("m")."-".date("t");
My sql then looks like
$sql = "select * from albumReviews where created >= '$startOfMonth' and created <= '$endOfMonth' "
This is fine for displaying the current month but i don't know how to adjust the $startOfMonth variable to a month other than the current.
i think i may have overcomplicated the situation but i feel i may have misunderstood the date/time functions of PHP and therefore made things more difficult for me. Even if someone can simply my variables or direct me to some tutorials (I've been using the PHP manual)
Thanks!
Stuart