Hello everone 🖐
I have an app that collects the birthdays of people and represent it in a repeater, the problem is that exctracted value from the date always differ that what it actually is, here's what I mean.
Here's the code that produces this:
let birthdayToday = [];
const today = new Date();
const day = today.toLocaleDateString('en-US', {day: 'numeric'})
const month = today.toLocaleDateString('en-US', {month: 'short'})
console.warn(`Today is ${day} ${month} 2020`)
contacts.items.forEach(contact => {
let contactDay = contact.birthday.toLocaleDateString('en-US', {day: 'numeric'})
let contactMon = contact.birthday.toLocaleDateString('en-US', {month: 'short'})
console.log(`Contact birthday: ${contactDay} ${contactMon}`)
if ( (day === contactDay) && (month === contactMon) ) { birthdayToday.push(contact) }
})
console.info(birthdayToday)
The first three (3) items in the database have their day to 9, which is today, but when getting their value they become 8 is in the console, and obviously, not items were pushed in the new array.
I did also the getDate() and getMonth() methods but they gave the same weird behaviour - a one month before (notice the picture below).
Also notice that the day that was assigned by code (not extracted from the collection) was correct in both methods. The issue occure when pulling data from the database.
Any thoughts? Is it a bug or what?
Thanks in advance.
Ahmad
Looked for it, and all I found was this updated setting, which I suppose covers the time zone that all collections on the site use:
Dashboard > Settings > Language & Region > Site Region > Time Zone