728x90
const moment = require('moment'); const now = moment(); const dateFormat = 'MMMM Do YYYY, h:mm:ss a'; console.log(`The current date and time is ${now.format(dateFormat)}.`); const dayOfWeek = now.format('dddd'); console.log(`Today is ${dayOfWeek}.`); const escapedYear = now.format('YYYY [escaped] YYYY'); console.log(`The current year is ${escapedYear}.`); const christmas = moment('2021-12-25'); const daysUntilChristmas = now.diff(christmas, 'days'); console.log(`There are ${daysUntilChristmas} days until Christmas.`); const tomorrow = now.add(1, 'day'); const tomorrowFormat = 'MMMM Do YYYY'; console.log(`Tomorrow will be ${tomorrow.format(tomorrowFormat)}.`); const endOfMonth = now.endOf('month'); const endOfMonthFormat = 'MMMM Do YYYY'; console.log(`The end of the month is ${endOfMonth.format(endOfMonthFormat)}.`); const lastWeek = now.subtract(1, 'week'); const lastWeekFormat = 'MMMM Do YYYY'; console.log(`Last week was ${lastWeek.format(lastWeekFormat)}.`); const nextYear = now.add(1, 'year'); const nextYearFormat = 'YYYY'; console.log(`Next year will be ${nextYear.format(nextYearFormat)}.`); const duration = moment.duration(now.diff(christmas)); console.log(`There are ${duration.days()} days, ${duration.hours()} hours, ${duration.minutes()} minutes, and ${duration.seconds()} seconds until Christmas.`);
728x90
'호그와트' 카테고리의 다른 글
쿠푸 왕의 피라미드 (0) | 2022.12.31 |
---|---|
Tryhackme Road (0) | 2022.12.30 |
colleciparis (0) | 2022.12.28 |
카뮈가 마시던 커퓌 (0) | 2022.12.28 |
으아아아아앙 쏠 수 있어 !! 지쨔 쏠 수 있어 !!! (1) | 2022.12.27 |