var weekStr = '일월화수목금토';

dayGap = 2000;


now = new Date();

newDay = new Date();

newDay.setDate(now.getDate() + dayGap);

newYear = newDay.getFullYear();

newMon = newDay.getMonth() +1;

newDate = newDay.getDate();

newWeekDay = weekStr.substr(newDay.getDay(),1);


document.write(now + ' + ' + dayGap + '일 = ');

document.write(newWeekDay + '요일 ' + newMon + '월 ' + newDate + '일 ' + newYear + '년');

document.write('<br>' + newDay);


3-2_CalDate.js


반응형

'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-1_PrintTime.js  (0) 2016.12.07
[JavaScript] 3-0_Variables and Functions  (0) 2016.12.07

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 + '초');


3-1_PrintTime.js


반응형

'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

<!DOCTYPE html>

<html>

<head>

<meta charset = "UTF-8">

<title>Javascript Variables and Functions</title>

</head>

<body>

<div id = "3-1">

<h3>3-1_PrintTIme.js</h3>

<script type = "text/javascript" src = "3-1_PrintTime.js"></script>

</div>

<div id = "3-2">

<h3>3-2_CalDates.js</h3>

<script type = "text/javascript" src = "3-2_CalDate.js"></script>

</div>

<div id = "3-3">

<h3>3-3_escapeFunc.js</h3>

<script type = "text/javascript" src = "3-3_escapeFunc.js"></script>

</div>

<div id = "3-4">

<h3>3-4_TypeCastFunc.js</h3>

<script type="text/javascript" src = "3-4_TypeCastFunc.js"></script>

</div>

<div id = "3-5">

<h3>3-5_evalFunc.js</h3>

<script type = "text/javascript" src = "3-5_evalFunc.js"></script>

</div>

<body>

</html>

3-0_Variables and Functions.html


반응형

'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-1_PrintTime.js  (0) 2016.12.07

+ Recent posts