Sunday, October 29, 2023

Event Calendar Vanilla Javascript

        const numDays = (y, m) => new Date(y, m, 0).getDate();

        console.log(numDays(2023, 10));


        let dayone = new Date(2023, 9, 1).getDay();

        console.log(dayone+" hari pertama di bulan ini 0 untuk minggu");


        // get the last date of the month

        let lastdate = new Date(2023, 9 + 1, 0).getDate();

        console.log(lastdate+" tanggal terakhir bulan ini");


        // get the day of the last date of the month

        let dayend = new Date(2023, 9, lastdate).getDay();

        console.log(dayend+" nama hari terakhir selasa di bulan ini");


        // get the last date of the previous month

        let monthlastdate = new Date(2023, 9, 0).getDate();

        console.log(monthlastdate+" tanggal terakhir dari bulan sebelumnya");

No comments:

Post a Comment

Dunia Programmer: Setiap Orang Punya Spesialisasinya, Lebih dari Sekadar Frontend dan Backend

Ketika mendengar kata programmer, kebanyakan orang mungkin langsung membaginya menjadi dua kategori, yaitu Frontend Developer dan Backend De...