Announcement: All noncommercial projects registered to use Earth Engine before
April 15, 2025 must
verify noncommercial eligibility to maintain Earth Engine access.
ee.Date.fromYMD
Stay organized with collections
Save and categorize content based on your preferences.
Returns a Date given year, month, day.
Usage | Returns | ee.Date.fromYMD(year, month, day, timeZone) | Date |
Argument | Type | Details | year | Integer | The year, 2013, for example. |
month | Integer | The month, 3, for example. |
day | Integer | The day, 15, for example. |
timeZone | String, default: null | The time zone (e.g., 'America/Los_Angeles'); defaults to UTC. |
Examples
Code Editor (JavaScript)
print('Date with default UTC',
ee.Date.fromYMD(2021, 4, 30));
print('Date with time zone specified',
ee.Date.fromYMD(2021, 4, 30, 'America/Los_Angeles'));
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)
display('Date with default UTC:', ee.Date.fromYMD(2021, 4, 30))
display(
'Date with time zone specified:',
ee.Date.fromYMD(2021, 4, 30, 'America/Los_Angeles')
)
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."],[[["\u003cp\u003e\u003ccode\u003eee.Date.fromYMD\u003c/code\u003e creates a Date object from year, month, and day inputs.\u003c/p\u003e\n"],["\u003cp\u003eThe function accepts optional \u003ccode\u003etimeZone\u003c/code\u003e argument to specify the time zone, defaulting to UTC if not provided.\u003c/p\u003e\n"],["\u003cp\u003eYou can use this function in both JavaScript and Python environments within Google Earth Engine.\u003c/p\u003e\n"]]],["The function `ee.Date.fromYMD` constructs a Date object using year, month, and day inputs, all of which are integers. Optionally, a `timeZone` string can be provided; otherwise, it defaults to UTC. The function returns a Date object. Examples are provided for both JavaScript and Python, demonstrating usage with and without specifying a time zone. The Python examples require the `ee` and `geemap` libraries.\n"],null,["# ee.Date.fromYMD\n\nReturns a Date given year, month, day.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|---------------------------------------------------|---------|\n| `ee.Date.fromYMD(year, month, day, `*timeZone*`)` | Date |\n\n| Argument | Type | Details |\n|------------|-----------------------|---------------------------------------------------------------|\n| `year` | Integer | The year, 2013, for example. |\n| `month` | Integer | The month, 3, for example. |\n| `day` | Integer | The day, 15, for example. |\n| `timeZone` | String, default: null | The time zone (e.g., 'America/Los_Angeles'); defaults to UTC. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\nprint('Date with default UTC',\n ee.Date.fromYMD(2021, 4, 30));\n\nprint('Date with time zone specified',\n ee.Date.fromYMD(2021, 4, 30, 'America/Los_Angeles'));\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\ndisplay('Date with default UTC:', ee.Date.fromYMD(2021, 4, 30))\n\ndisplay(\n 'Date with time zone specified:',\n ee.Date.fromYMD(2021, 4, 30, 'America/Los_Angeles')\n)\n```"]]