I dont see $date getting defined if it is not over a day...Maybe I missed something though.