'How to get Google Scripts dateFilter to find GooglePhotos dated today on 1st of month?
Maybe it's my timzone (Sydney)?
On the first of the month, every month, I cannot get a Google Photos request to see photos from the current day. I know the files exist, but I can't find a date filter that will return them.
I've tried "ranges" with startDate yesterday (or earlier) and endDates today, tomorrow or even next month.
I've tried "dates" with year and month only (day is therefore a wildcard). Including dates of just this month, or both last month and this. Regardless, nothing will see photos from today.
This happens every month, the files are just invisible. Sometime in the first few days of the month, they become visible and everything works again.
Most of the time, this code works as I expect:
var now = new Date();
var from = new Date();
from.setDate(now.getDate()-2); //Two days before
var tomo = new Date();
tomo.setDate(now.getDate()+1); //One day after
var request = {
"pageSize":"50", // maximum is 100
"filters": {
"dateFilter": {
"ranges": [ { "startDate": { "year": from.getFullYear(), "month": from.getMonth()+1, "day": from.getDate() },
"endDate": { "year": tomo.getFullYear(), "month": tomo.getMonth()+1, "day": tomo.getDate() } ]
}
}
};
I've tried replacing the range by these wildcard dates.
"dates": [ {"year": from.getFullYear(), "month": from.getMonth()+1},
{"year": tomo.getFullYear(), "month": tomo.getMonth()+1}
]
Logs show that all the files in the previous month are returned but nothing from the current month. Out of desparation, I've even tried requesting all the files from the current YEAR.
"dates": [ {"year": from.getFullYear()}]
Everything from yesterday back to the beginning of the year is returned, but nothing from today.
What am I missing?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
