Prettify date generic

errorMsg added as parameter of the helper