Created
April 1, 2016 06:20
-
-
Save vishalbasnet23/3ccf96a6af4d9ecc570f5d6e94539a23 to your computer and use it in GitHub Desktop.
Safari fix for date NaN issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function formatDate(createdDate) { | |
var monthNames = [ | |
"Jan", "Feb", "Mar", | |
"Apr", "May", "Jun", "Jul", | |
"Aug", "Sep", "Oct", | |
"Nov", "Dec" | |
]; | |
var parsedDate = Date.parse(createdDate); | |
// alert(parsedDate); | |
var date = new Date(createdDate.replace(/\s/, 'T')); | |
var day = date.getDate(); | |
var monthIndex = date.getMonth(); | |
var year = date.getFullYear(); | |
return day + ' ' + monthNames[monthIndex] + ' ' + year; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment