I've got a date field, and I'm grabbing the month and year from the url. What I'm after is to display all the events within the month, but for some reason I can't get this to work
{% set firstDayOfMonth = month ~ "/1/" ~ year|date("U") %} // returns the 1st day of the month in unixtime
{% set daysInThisMonth = firstDayOfMonth|date('t') %}
{% set lastDayOfMonth = month ~ "/" ~ daysInThisMonth ~ "/" ~ year|date("U") %} // returns the last day of the month in unixtime
{% set thisMonthsEvents = craft.entries.section('events').eventDate('and', '>= ' ~ firstDayOfMonth, '<= ' ~ lastDayOfMonth) %}
{% if thisMonthsEvents | length %}
some events
{% else %}
no events
{% endif %}
Any ideas? firstDayOfMonth and lastDayOfMonth return dates fine, but no matter how I format them, the result is no entries returned. For example, firstDayOfTheMonth could output "2014-6-01" and lastDayOfMonth could output "2014-6-30", and I've got an event with an eventDate of 18th June 2014, but nothing is being returned.