var weekstr = '일월화수목금토';
var now = new Date();
document.write(now + '<br>');
//getYear()을 하면 왜 116?
year = now.getYear();
year = now.getFullYear();
//getMonoth()를 통해 가져온 월은 Zero-base
month = now.getMonth();
++month;
date = now.getDate();
hour = now.getHours();
min = now.getMinutes();
sec = now.getSeconds();
mils = now.getMilliseconds();
weekDays = now.getDay();
document.write(year + '년 ' + month + '월 ' + date + '일 ' + weekstr.substr(weekDays,1) + '요일');
document.write('<br>');
document.write(hour + '시 ' + min + '분 ' + sec + '.' + mils + '초');
반응형
'Programming > JavaScript' 카테고리의 다른 글
[JavaScript] 3-5_evalFunc.js (0) | 2016.12.07 |
---|---|
[JavaScript] 3-4_TypeCastFunc.js (0) | 2016.12.07 |
[JavaScript] 3-3_escapeFunc.js (0) | 2016.12.07 |
[JavaScript] 3-2_CalDate.js (0) | 2016.12.07 |
[JavaScript] 3-0_Variables and Functions (0) | 2016.12.07 |