Skip to content

Instantly share code, notes, and snippets.

@s-hiroshi
Created June 13, 2012 06:47
Show Gist options
  • Save s-hiroshi/2922388 to your computer and use it in GitHub Desktop.
Save s-hiroshi/2922388 to your computer and use it in GitHub Desktop.
JavaScript > custom function > date
//日付表記を変換
function changeDate(str) {
var myDate = new Date(str);
var YYYY = myDate.getFullYear();
var MM = myDate.getMonth() + 1;
if (MM < 10) {
MM = "0" + MM;
}
var DD = myDate.getDate();
if (DD < 10) {
DD = "0" + DD;
}
var date = YYYY + "/" + MM + "/" + DD;
return date;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment