Category : momentjs

Good day everybody, I have a firetore collection of docs which all have a dateCreated field of timestamp data type. I want to select all the docs where dateCreated is today. How would I achieve this. I have tried below with no success const ref = firestore.collection(‘orders’).where(‘dateCreated’,'<‘,moment().toDate()).orderBy(‘dateCreated’, ‘desc’); The above line gets all the orders ..

Read more

I have a problem with converting date time which comes from datepicker to moment (I use this library) time format. What I get from datepicker: 2021-01-30T07:00:00.000Z The code that I used via moment: let tempTime = moment(dateString).toDate() Output I get with this implementation: Fri Apr 30 2021 00:00:00 GMT-0700 (Mountain Standard Time) What I expected: ..

Read more

const all = [{ “startTime”: “2021-04-26T08:00:00”, “endTime”: “2021-04-26T11:00:00” }, { “startTime”: “2021-04-27T10:00:00”, “endTime”: “2021-01-27T13:00:00” }] desiredoutput = [ “2021-04-26T08:00:00”, “2021-04-26T09:00:00”, “2021-04-26T10:00:00”, “2021-04-26T11:00:00”, “2021-04-26T12:00:00”, “2021-04-27T10:00:00”, “2021-04-27T12:00:00”, “2021-04-27T13:00:00” ] const findTrueAllTime = all.map(({startTime, endTime}) => ({startTime, endTime})) const getAllTimeRange = findTrueAllTime.map(({ startTime, endTime}) => { const timeStart = new Date(startTime).getHours(); const timeEnd = new Date(endTime).getHours(); const hourDiff ..

Read more