ee.Date.getRange

Returns a DateRange covering the unit of the specified type that contains this date, e.g. Date('2013-3-15').getRange('year') returns DateRange('2013-1-1', '2014-1-1').
UsageReturns
Date.getRange(unit, timeZone)DateRange
ArgumentTypeDetails
this: dateDate
unitStringOne of 'year', 'month' 'week', 'day', 'hour', 'minute', or 'second'.
timeZoneString, default: nullThe time zone (e.g. 'America/Los_Angeles'); defaults to UTC.

Examples

Code Editor (JavaScript)

var date = ee.Date('2021-4-30T07:15:31.24');

print('1-year date range covering input date', date.getRange('year'));
print('1-month date range covering input date', date.getRange('month'));
print('1-week date range covering input date', date.getRange('week'));
print('1-day date range covering input date', date.getRange('day'));
print('1-hour date range covering input date', date.getRange('hour'));
print('1-minute date range covering input date', date.getRange('minute'));
print('1-second date range covering input date', date.getRange('second'));