公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
ee.Date.fromYMD
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
返回指定年、月、日的日期。
用法 | 返回 |
---|
ee.Date.fromYMD(year, month, day, timeZone) | 日期 |
参数 | 类型 | 详细信息 |
---|
year | 整数 | 例如,2013 年。 |
month | 整数 | 月份,例如 3。 |
day | 整数 | 日期,例如 15。 |
timeZone | 字符串,默认值:null | 时区(例如,“America/Los_Angeles”);默认为 UTC。 |
示例
代码编辑器 (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 设置
如需了解 Python API 和如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
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')
)
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\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```"]]