moved calculating the date to PHP