Avant ta boucle tu initialise une variable

$datePrecedente = '';
Au tout début de ta boucle tu ajoute une variable :

$dateCourante =...