Announcement: On
November 13, 2024, all users will need to
use a Cloud project in order to access Earth Engine. After this date, continued individual access without a Cloud project will require
an exception.
ee.Date.get
Returns the specified unit of this date.
Usage | Returns | Date.get(unit, timeZone) | Long |
Argument | Type | Details | this: date | Date | |
unit | String | One of 'year', 'month' (returns 1-12), 'week' (1-53), 'day' (1-31), 'hour' (0-23), 'minute' (0-59), or 'second' (0-59). |
timeZone | String, default: null | The time zone (e.g., 'America/Los_Angeles'); defaults to UTC. |
Examples
Code Editor (JavaScript)
var date = ee.Date('2021-4-30T07:15:31');
print('Year', date.get('year'));
print('Month', date.get('month'));
print('Week', date.get('week'));
print('Day', date.get('day'));
print('Hour', date.get('hour'));
print('Minute', date.get('minute'));
print('Second', date.get('second'));
Python setup
See the
Python Environment page for information on the Python API and using
geemap
for interactive development.
import ee
import geemap.core as geemap
Colab (Python)
date = ee.Date('2021-4-30T07:15:31')
display('Year:', date.get('year'))
display('Month:', date.get('month'))
display('Week:', date.get('week'))
display('Day:', date.get('day'))
display('Hour:', date.get('hour'))
display('Minute:', date.get('minute'))
display('Second:', date.get('second'))
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-13 UTC.
[null,null,["Last updated 2024-07-13 UTC."],[[["The `Date.get()` function retrieves a specific unit (year, month, week, day, hour, minute, or second) from a given date object."],["The function takes the desired unit as a string argument and an optional time zone argument, defaulting to UTC if not specified."],["Returned values are represented as a long integer, with months ranging from 1-12, weeks from 1-53, days from 1-31, hours from 0-23, minutes from 0-59, and seconds from 0-59."],["Examples demonstrate how to use the function with various units in both JavaScript and Python environments within Google Earth Engine."]]],[]]