to_datetime#

geetools.ee_date.DateAccessor.to_datetime(tz=ZoneInfo('UTC'))#

Convert a ee.Date to a datetime.datetime.

Since ee.Date object is not timezone aware, there is no way to get the timezone from it, thus it must be passed as argument.

Parameters:

tz (str | zoneinfo.ZoneInfo) – time zone, defaulted to “UTC”. Other names can be found here: https://www.joda.org/joda-time/timezones.html

Returns:

The datetime.datetime representation of the ee.Date.

Return type:

datetime.datetime

Examples

import ee, geetools
from geetools.utils import initialize_documentation

initialize_documentation()

d = ee.Date('2020-01-01').geetools.to_datetime()
d.strftime('%Y-%m-%d')
'2020-01-01'