I believe the problem is not with YOUR code. I forgot that JavaScript Date object is zero-based. So Date(2015, 05, 31) is NOT May 31.