ee.Date.parse
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.
Phân tích cú pháp chuỗi ngày, với một chuỗi mô tả định dạng của chuỗi ngày đó.
Cách sử dụng | Giá trị trả về |
---|
ee.Date.parse(format, date, timeZone) | Ngày |
Đối số | Loại | Thông tin chi tiết |
---|
format | Chuỗi | Một mẫu, như mô tả tại http://joda-time.sourceforge.net/apidocs/org/joda/time/format/DateTimeFormat.html. |
date | Chuỗi | Một chuỗi khớp với mẫu đã cho. |
timeZone | Chuỗi, mặc định: rỗng | Múi giờ (ví dụ: 'America/Los_Angeles'); mặc định là UTC. |
Ví dụ
Trình soạn thảo mã (JavaScript)
print(ee.Date.parse('yyyy MM dd', '2021 4 30'));
print(ee.Date.parse('yyyy-MM-dd', '2021-4-30'));
print(ee.Date.parse('yyyy/MM/dd', '2021/4/30'));
print(ee.Date.parse('MM/dd/yy', '4/30/21'));
print(ee.Date.parse('MMM. dd, yyyy', 'Apr. 30, 2021'));
print(ee.Date.parse('yyyy-MM-dd HH:mm:ss', '2021-4-30 00:00:00'));
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
để phát triển tương tác.
import ee
import geemap.core as geemap
Colab (Python)
display(ee.Date.parse('YYYY MM dd', '2021 4 30'))
display(ee.Date.parse('YYYY-MM-dd', '2021-4-30'))
display(ee.Date.parse('YYYY/MM/dd', '2021/4/30'))
display(ee.Date.parse('MM/dd/YY', '4/30/21'))
display(ee.Date.parse('MMM. dd, YYYY', 'Apr. 30, 2021'))
display(ee.Date.parse('YYYY-MM-dd HH:mm:ss', '2021-4-30 00:00:00'))
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-25 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-25 UTC."],[[["\u003cp\u003e\u003ccode\u003eee.Date.parse()\u003c/code\u003e allows you to convert a date string into a Date object by specifying the string's format.\u003c/p\u003e\n"],["\u003cp\u003eIt accepts a format pattern based on Joda-Time's DateTimeFormat, the date string itself, and an optional time zone (defaulting to UTC).\u003c/p\u003e\n"],["\u003cp\u003eVarious format patterns can be used, such as 'YYYY MM dd', 'YYYY-MM-dd', 'YYYY/MM/dd', 'MM/dd/YY', 'MMM.dd, YYYY', and 'YYYY-MM-dd HH:mm:ss'.\u003c/p\u003e\n"]]],["The `ee.Date.parse` function converts a date string into a Date object. It requires a `format` string, following Joda-Time patterns, to define the structure of the input `date` string. An optional `timeZone` can be specified, defaulting to UTC. Valid examples are provided and demostrated for various formats like 'yyyy MM dd', 'yyyy-MM-dd' or 'MM/dd/yy'. The function will return a new date based on the parsing of the date string.\n"],null,["# ee.Date.parse\n\nParse a date string, given a string describing its format.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|---------------------------------------------|---------|\n| `ee.Date.parse(format, date, `*timeZone*`)` | Date |\n\n| Argument | Type | Details |\n|------------|-----------------------|---------------------------------------------------------------------------------------------------------------|\n| `format` | String | A pattern, as described at http://joda-time.sourceforge.net/apidocs/org/joda/time/format/DateTimeFormat.html. |\n| `date` | String | A string matching the given pattern. |\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(ee.Date.parse('yyyy MM dd', '2021 4 30'));\nprint(ee.Date.parse('yyyy-MM-dd', '2021-4-30'));\nprint(ee.Date.parse('yyyy/MM/dd', '2021/4/30'));\nprint(ee.Date.parse('MM/dd/yy', '4/30/21'));\nprint(ee.Date.parse('MMM. dd, yyyy', 'Apr. 30, 2021'));\nprint(ee.Date.parse('yyyy-MM-dd HH:mm:ss', '2021-4-30 00:00:00'));\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(ee.Date.parse('YYYY MM dd', '2021 4 30'))\ndisplay(ee.Date.parse('YYYY-MM-dd', '2021-4-30'))\ndisplay(ee.Date.parse('YYYY/MM/dd', '2021/4/30'))\ndisplay(ee.Date.parse('MM/dd/YY', '4/30/21'))\ndisplay(ee.Date.parse('MMM. dd, YYYY', 'Apr. 30, 2021'))\ndisplay(ee.Date.parse('YYYY-MM-dd HH:mm:ss', '2021-4-30 00:00:00'))\n```"]]