Actually this is wrong ... what you want is date.setDate(0);