Program JavaScript untuk Mengonversi Tanggal ke Angka

Contoh: Konversi Tanggal ke Angka // program to convert date to number // create date const d1 = new Date(); console.log(d1); // converting to number const result = d1.getTime(); console.log(result); Keluaran Mon Nov 09 2020 10:52:32 GMT+0545 (Nepal Time) 1604898452084 Dalam contoh di atas, new Date() konstruktor digunakan untuk membuat objek tanggal. Itu new Date() […]

Read more »

Program JavaScript untuk Membandingkan Nilai Dua Tanggal

Contoh: Bandingkan Nilai Dua Tanggal // program to compare value of two dates // create two dates const d1 = new Date(); const d2 = new Date(); // comparisons const compare1 = d1 < d2; console.log(compare1); const compare2 = d1 > d2; console.log(compare2); const compare3 = d1 <= d2; console.log(compare3); const compare4 = d1 >= […]

Read more »

Program Javascript untuk Menampilkan Tanggal Saat Ini

Contoh : Menampilkan Tanggal Saat Ini // program to display the date // get local machine date time const date = new Date(); // get the date as a string const n = date.toDateString(); // get the time as a string const time = date.toLocaleTimeString(); // display date console.log(‘Date: ‘ + n); // display time […]

Read more »

Program JavaScript untuk Memformat Tanggal

Contoh 1: Format Tanggal // program to format the date // get current date let currentDate = new Date(); // get the day from the date let day = currentDate.getDate(); // get the month from the date // + 1 because month starts from 0 let month = currentDate.getMonth() + 1; // get the year […]

Read more »

Program JavaScript untuk Menampilkan Tanggal dan Waktu

Contoh : Tampilan Tanggal dan Waktu // program to display the date and time // get date and time const date = new Date(2017, 2, 12, 9, 25, 30); // get the date as a string const n = date.toDateString(); // get the time as a string const time = date.toLocaleTimeString(); // display date console.log(‘Date: […]

Read more »

Notice: ob_end_flush(): failed to send buffer of zlib output compression (0) in /home/breatgem/widiyanata.com/wp-includes/functions.php on line 4755