Notice
Recent Posts
Recent Comments
준호씨의 블로그
javascript - date yyyymmdd, hhmmss, yyyymmddhhmmss, yyyymmddhhmm 본문
반응형
yyyymmdd
Date.prototype.yyyymmdd = function() {
var mm = this.getMonth() + 1;
var dd = this.getDate();
return [this.getFullYear(),
(mm>9 ? '' : '0') + mm,
(dd>9 ? '' : '0') + dd
].join('');
};
var date = new Date();
date.yyyymmdd();
output
"20180703"
hhmmss
Date.prototype.hhmmss = function() {
var hh = this.getHours();
var mm = this.getMinutes();
var ss = this.getSeconds();
return [(hh>9 ? '' : '0') + hh,
(mm>9 ? '' : '0') + mm,
(ss>9 ? '' : '0') + ss,
].join('');
};
var date = new Date();
date.hhmmss();
output
"165731"
yyyymmddhhmmss
Date.prototype.yyyymmddhhmmss = function() {
return this.yyyymmdd() + this.hhmmss();
};
var date = new Date();
date.yyyymmddhhmmss();
output
"20180703165742"
yyyymmddhhmm
date.yyyymmddhhmmss().substring(0,12)
output
"201807031657"
참고
반응형
'개발이야기' 카테고리의 다른 글
java - 홀수, 짝수 구분하기. check even, odd number (0) | 2018.07.19 |
---|---|
perl - template toolkit (tt) 반복문 (0) | 2018.07.16 |
perl - sort hash. by key, by value. hash 정렬하기. (0) | 2018.07.10 |
git clone 디렉토리 지정하기 (0) | 2018.07.10 |
osx - dyld: Library not loaded. Reason: image not found. DYLD_LIBRARY_PATH 설정 (0) | 2018.07.02 |
Comments