ee.Date.fromYMD
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Trả về một Ngày theo năm, tháng, ngày.
Cách sử dụng | Giá trị trả về |
---|
ee.Date.fromYMD(year, month, day, timeZone) | Ngày |
Đối số | Loại | Thông tin chi tiết |
---|
year | Số nguyên | Ví dụ: năm 2013. |
month | Số nguyên | Tháng, ví dụ: 3. |
day | Số nguyên | Ngày, ví dụ: 15. |
timeZone | Chuỗi, mặc định: null | Múi giờ (ví dụ: "America/Los_Angeles"); mặc định là UTC. |
Ví dụ
Trình soạn thảo mã (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'));
Thiết lập Python
Hãy xem trang
Môi trường Python để biết thông tin về API Python và cách sử dụng geemap
cho quá trình phát triển tương tác.
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')
)
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-26 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-26 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```"]]