Problem with determing months
dirkgently <[email protected]>
| Newsgroups | gmane.comp.web.oscommerce.general |
|---|---|
| Message-ID | <38399dd60358eb0e101c182919a99184@osCommerce-Forums> |
This message was sent from: General Support
http://forums.oscommerce.com/viewtopic.php?p=227946#227946
----------------------------------------------------------------
I'm writing (or at least attempting to) a contrib to display only new products for months as selected by the customer. For the current month the code below works fine, but for everything else it gets it screwed up. Basically the start and end dates are used as part of the sql query.
When it works (ie current month), Start Date is '2003-09-01 00:00:00' and End Date is '2003-10-01 00:00:00' which is okay.
When it fails (any other month, before of after this month, Start Date is '2003-10/year_id=-01 00:00:00' and End Date is '2003-11-01 00:00:00' (example of one month ahead). So, Start date is wrong, but end date is okay.
Can anyone help me out with a bit of PHP code here. The stuff below works, but only for the current month. I have gone through this time and time again and can not see what is wrong.
[code]$search_month = ($HTTP_GET_VARS['month_id']);
$search_year = ($HTTP_GET_VARS['year_id']);
if (strlen ($search_month) == 1)
$start_month = ("0" . $search_month);
else
$start_month = $search_month;
$end_month = ($start_month + 1);
$start_year = (date("Y")+$search_year);
$end_year = (date("Y")+$search_year);
if ($end_month == 13) {
$end_month = 01;
$end_year = (date("Y") +1); }
$start_date = ($start_year . "-" . $start_month . "-01" . " 00:00:00");
$end_date = ($end_year . "-" . $end_month . "-01" . " 00:00:00");[/code]
Anyone any ideas? Any help will be gratefully received, and once the contrib is complete, I'll even give you credit in the readme. I'm developing on 2.2MS2 in case that has any bearing