From 8644699f4d2fce12a41289f9627bc45be9dd1965 Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Thu, 3 Dec 2020 09:32:13 +0700 Subject: [usth/ICT3.2] Develop web applications --- usth/ICT3.2/prac/2/1.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 usth/ICT3.2/prac/2/1.js (limited to 'usth/ICT3.2/prac/2/1.js') diff --git a/usth/ICT3.2/prac/2/1.js b/usth/ICT3.2/prac/2/1.js new file mode 100644 index 0000000..ecc78f2 --- /dev/null +++ b/usth/ICT3.2/prac/2/1.js @@ -0,0 +1,9 @@ +const DAYS = ['Monday', 'Tuesday', 'Wednesday', + 'Thursday', 'Friday', 'Saturday', 'Sunday']; +const NOW = new Date(); +const HOUR24 = NOW.getHours(); +const HOUR12 = HOUR24 % 12; +const PERIOD = HOUR24 < 12 ? 'AM' : 'PM'; + +console.log(`Today is: ${DAYS[NOW.getDay()-1]}`); +console.log(`Current time is: ${HOUR12} ${PERIOD}: ${NOW.getMinutes()}: ${NOW.getSeconds()}`) -- cgit 1.4.1