Fix to JS error in date formating