박지환

Test time set

...@@ -32,15 +32,26 @@ app.use(static(__dirname)); ...@@ -32,15 +32,26 @@ app.use(static(__dirname));
32 32
33 // To get today date by using Date 33 // To get today date by using Date
34 function getTodayDate() { 34 function getTodayDate() {
35 - var today = new Date(); 35 + var tempDate = new Date();
36 + const utc = tempDate.getTime() + tempDate.getTimezoneOffset() * 60 * 1000;
37 + const KR_TIME_DIFF = 9 * 60 * 60 * 1000;
38 + const today = new Date(utc + KR_TIME_DIFF);
39 + console.log(today);
36 var year = today.getFullYear(); 40 var year = today.getFullYear();
37 var month = ("0" + (today.getMonth() + 1)).slice(-2); 41 var month = ("0" + (today.getMonth() + 1)).slice(-2);
38 var day = ("0" + today.getDate()).slice(-2); 42 var day = ("0" + today.getDate()).slice(-2);
39 var dateString = year + "-" + month + "-" + day; 43 var dateString = year + "-" + month + "-" + day;
40 - //return "2022-12-25"; // 테스트용 날짜를 입력하세요. *** 테스트가 끝나면 주석처리하고 커밋해주세요. *** ex) 2022-09-12, 2022-09-15, 2022-10-04 44 + // return "2022-12-25"; // 테스트용 날짜를 입력하세요. *** 테스트가 끝나면 주석처리하고 커밋해주세요. *** ex) 2022-09-12, 2022-09-15, 2022-10-04
41 return dateString; 45 return dateString;
42 } 46 }
43 47
48 +function test() {
49 + var tempDate = new Date(); // Locale time
50 + const utc = tempDate.getTime() + tempDate.getTimezoneOffset() * 60 * 1000; // Calculate UTC time
51 + const KR_TIME_DIFF = 9 * 60 * 60 * 1000; // UTC to KST (UTC + 9 hours)
52 + return utc + KR_TIME_DIFF;
53 +}
54 +
44 // To get modified date from locdate 55 // To get modified date from locdate
45 function getModifiedDate(locdate) { 56 function getModifiedDate(locdate) {
46 return ( 57 return (
...@@ -202,6 +213,11 @@ app.get("/app", function (req, res) { ...@@ -202,6 +213,11 @@ app.get("/app", function (req, res) {
202 ); 213 );
203 }); 214 });
204 215
216 +app.get("/test", function (req, res) {
217 + init();
218 + res.send(Date() + "<br>" + Date(test()) + "<br>" + test());
219 +});
220 +
205 init(); 221 init();
206 222
207 const port = 8080; 223 const port = 8080;
......