Skip to content

Instantly share code, notes, and snippets.

@remyzv
Last active August 29, 2015 13:57
Show Gist options
  • Save remyzv/9599347 to your computer and use it in GitHub Desktop.
Save remyzv/9599347 to your computer and use it in GitHub Desktop.
Utiliy function for js date
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