AI-generated Key Takeaways
-
ee.DateRange
creates a range of dates, allowing you to specify a start and end date (inclusive and exclusive, respectively). -
Start and end dates can be provided as Dates, numbers (milliseconds since epoch), or strings (e.g., 'YYYY-MM-DD' or 'YYYY-MM-DDTHH:mm:ss').
-
If only a start date is given, a 1-millisecond range is created starting at that date.
-
You can specify the time zone for string inputs using the optional
timeZone
argument, which defaults to UTC. -
ee.DateRange
is essential for temporal filtering and analysis in Earth Engine.
Usage | Returns |
---|---|
ee.DateRange(start, end, timeZone) | DateRange |
Argument | Type | Details |
---|---|---|
start | Object | |
end | Object, default: null | |
timeZone | String, default: null | If start and/or end are provided as strings, the time zone in which to interpret them; defaults to UTC. |
Examples
Code Editor (JavaScript)
print('String date inputs (interpreted as UTC by default)', ee.DateRange('2017-06-24', '2017-07-24')); print('String date inputs with timeZone argument', ee.DateRange('2017-06-24', '2017-07-24', 'America/Los_Angeles')); print('String date-time inputs with timeZone argument', ee.DateRange('2017-06-24T07:00:00', '2017-07-24T07:00:00', 'America/Los_Angeles')); print('A single date input results in a 1-millisecond range', ee.DateRange('2017-06-24')); print('ee.Date inputs', ee.DateRange(ee.Date('2017-06-24'), ee.Date('2017-07-24'))); print('ee.Date date-time inputs (UTC by default)', ee.DateRange(ee.Date('2017-06-24T07:00:00'), ee.Date('2017-07-24T07:00:00'))); print('ee.Date date-time inputs with timeZone arguments', ee.DateRange(ee.Date('2017-06-24T07:00:00', 'UTC'), ee.Date('2017-07-24T07:00:00', 'America/Los_Angeles'))); print('Number inputs as milliseconds from Unix epoch (2017-06-24, 2017-07-24)', ee.DateRange(1498262400000, 1500854400000));
import ee import geemap.core as geemap
Colab (Python)
print('String date inputs (interpreted as UTC by default):', ee.DateRange('2017-06-24', '2017-07-24').getInfo()) print('String date inputs with timeZone argument:', ee.DateRange('2017-06-24', '2017-07-24', 'America/Los_Angeles').getInfo()) print('String date-time inputs with timeZone argument:', ee.DateRange('2017-06-24T07:00:00', '2017-07-24T07:00:00', 'America/Los_Angeles').getInfo()) print('A single date input results in a 1-millisecond range:', ee.DateRange('2017-06-24').getInfo()) print('ee.Date inputs', ee.DateRange(ee.Date('2017-06-24'), ee.Date('2017-07-24')).getInfo()) print('ee.Date date-time inputs (UTC by default):', ee.DateRange(ee.Date('2017-06-24T07:00:00'), ee.Date('2017-07-24T07:00:00')).getInfo()) print('ee.Date date-time inputs with timeZone arguments:', ee.DateRange(ee.Date('2017-06-24T07:00:00', 'UTC'), ee.Date('2017-07-24T07:00:00', 'America/Los_Angeles')).getInfo()) print('Number inputs as milliseconds from Unix epoch (2017-06-24, 2017-07-24):', ee.DateRange(1498262400000, 1500854400000).getInfo())