Last active
August 29, 2015 13:57
-
-
Save remyzv/9599347 to your computer and use it in GitHub Desktop.
Utiliy function for js date
This file contains 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 parseDate(date) { | |
var year = parseInt(date.substring(0,4)); | |
var month = parseInt(date.substring(4,6)); | |
month = (month < 10) ? '0' + month : month; | |
month = month-1; | |
var day = parseInt(date.substring(6,9)); | |
day = (day < 10) ? '0' + day : day; | |
return new Date(year,month,day); | |
} | |
function displayDate(date,separator) { | |
var day = date.getDate(); | |
var month = date.getMonth(); | |
var year = date.getFullYear(); | |
month = (month < 10) ? '0' + month : month; | |
month = month-1; | |
day = (day < 10) ? '0' + day : day; | |
return day+separator+month+separator+year; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment