[Javascript]Javasriptでtomorrow取得

Javasriptでtomorrow取得

            const today = new Date();
            
            const tomorrow = new Date(today);
            tomorrow.setDate(tomorrow.getDate() + 1);

            const yyyyTomorrow = tomorrow.getFullYear();
            let mmTomorrow = tomorrow.getMonth() + 1;
            let ddTomorrow = tomorrow.getDate();
            const yyyymmddTomorrow = yyyyTomorrow + "," + mmTomorrow + "," + ddTomorrow;
            console.log('yyyymmddTomorrow:'+yyyymmddTomorrow);

            var endDate = new Date(yyyymmddTomorrow);
            console.log('endDate:'+endDate);

[Firebase]クエリでendAt使用例

クエリでendAt使用例

            const today = new Date();
            const yyyy = today.getFullYear();
            let mm = today.getMonth() + 1;
            let dd = today.getDate();
            const yyyymmdd = yyyy + "," + mm + "," + dd;
            var startDate = new Date(yyyymmdd);

            const tomorrow = new Date(today);
            tomorrow.setDate(tomorrow.getDate() + 1);

            const yyyyTomorrow = tomorrow.getFullYear();
            let mmTomorrow = tomorrow.getMonth() + 1;
            let ddTomorrow = tomorrow.getDate();
            const yyyymmddTomorrow = yyyyTomorrow + "," + mmTomorrow + "," + ddTomorrow;
            console.log('yyyymmddTomorrow:'+yyyymmddTomorrow);

            var endDate = new Date(yyyymmddTomorrow);
            console.log('endDate:'+endDate);
            
            firebase.firestore()
            .collectionGroup("samplecollection") 
            .orderBy("createdAt", "asc").startAt(startDate).endAt(endDate)
            .limit(10)
            .get()
            .then(querySnapshot => {
                querySnapshot.forEach(doc => {
                    console.log('success');
                }, (error) => {
                    console.log('error');
                });
            })