Fixed formatDate function not returning anything