I have the following function to pull in comments only from the current month. I need it to not pull any comments from the next month.
I have the next month defined as $to_date with a +1 how can I change this to automatically figure out when it is in the next year ie prevent it from looking in month 13? Thanks
Function to only pull comments from a date range of the current month
$from_date = date('Y-m') . '1 00:00:00';
$to_date = date('m') . '1 00:00:00'+1;
$all_comments = Comment::find('all',
array(
'conditions'=>array('response_date_and_time >= ? AND response_date_and_time <= ?', $from_date, $to_date )
)
);
strototime can do this for you. You can use the keyword “now + 1 month” which will take the current date +1 and return the unix timestamp, which the date function will turn into the correct month. Should return 02