Added general function for formatting date