公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
ee.Date
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
构造新的 Date 对象。
参数 | 类型 | 详细信息 |
---|
date | ComputedObject|Date|Number|String | 要转换的日期,可以是以下任一类型:数字(自纪元以来的毫秒数)、ISO 日期字符串、JavaScript Date 或 ComputedObject。 |
tz | 字符串,可选 | 一个可选的时区,仅用于字符串日期。 |
示例
代码编辑器 (JavaScript)
// Numeric inputs are interpreted as milliseconds from Unix epoch.
print(ee.Date(0)); // Date (1970-01-01 00:00:00)
// Scale factors can make numerical inputs more readable (e.g. 60 seconds).
print(ee.Date(60 * 1000)); // Date (1970-01-01 00:01:00)
// ISO 8601 date string input examples.
print(ee.Date('2020')); // Date (2020-01-01 00:00:00)
print(ee.Date('2017-6-24')); // Date (2017-06-24 00:00:00)
print(ee.Date('2017-06-24')); // Date (2017-06-24 00:00:00)
print(ee.Date('2017-6-24T00:14:46')); // Date (2017-06-24 00:14:46)
print(ee.Date('2017-06-24T23:59:59')); // Date (2017-06-24 23:59:59)
// With an optional time zone.
print(ee.Date('2020', 'US/Mountain')); // Date (2020-01-01T07:00:00)
// Convert JavaScript now to Earth Engine Date
print(ee.Date(Date.now()));
Python 设置
如需了解 Python API 和如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
import ee
import geemap.core as geemap
Colab (Python)
from datetime import datetime
# Numeric inputs are interpreted as milliseconds from Unix epoch.
print(ee.Date(0).format().getInfo()) # 1970-01-01T00:00:00
# Scale factors can make numerical inputs more readable (e.g. 60 seconds).
print(ee.Date(60 * 1000).format().getInfo()) # 1970-01-01T00:01:00
# ISO 8601 date string input examples.
print(ee.Date('2020').format().getInfo()) # 2020-01-01T00:00:00
print(ee.Date('2017-6-24').format().getInfo()) # 2017-06-24T00:00:00
print(ee.Date('2017-06-24').format().getInfo()) # 2017-06-24T00:00:00
print(ee.Date('2017-6-24T00:14:46').format().getInfo()) # 2017-06-24T00:14:46
print(ee.Date('2017-06-24T23:59:59').format().getInfo()) # 2017-06-24T23:59:59
# With an optional time zone.
print(ee.Date('2020', 'US/Mountain').format().getInfo()) # 2020-01-01T07:00:00
# Convert Python datetime.now() to Earth Engine Date
print(ee.Date(datetime.now()).format().getInfo())
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eThe \u003ccode\u003eee.Date()\u003c/code\u003e constructor creates a new Date object in Earth Engine.\u003c/p\u003e\n"],["\u003cp\u003eIt accepts various input types for the date: a number (milliseconds since epoch), an ISO Date string, a JavaScript Date, or a ComputedObject.\u003c/p\u003e\n"],["\u003cp\u003eAn optional timezone argument (\u003ccode\u003etz\u003c/code\u003e) can be provided when using a string date input.\u003c/p\u003e\n"],["\u003cp\u003eNumerical inputs can be scaled for readability, like using 60 * 1000 to represent 60 seconds.\u003c/p\u003e\n"],["\u003cp\u003eExamples demonstrate creating dates from different inputs and formatting them using \u003ccode\u003eformat().getInfo()\u003c/code\u003e.\u003c/p\u003e\n"]]],["The `ee.Date` function creates a new Date object, accepting various inputs: milliseconds since the epoch, ISO date strings, JavaScript Dates, or ComputedObjects. It can use numeric inputs, interpreted as milliseconds, or date strings following ISO 8601 format. An optional timezone argument (string) can be provided with string date input to specify the timezone. The function returns a Date object and examples in JavaScript and Python are provided.\n"],null,["# ee.Date\n\n\u003cbr /\u003e\n\nConstructs a new Date object.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|-------------------------|---------|\n| `ee.Date(date, `*tz*`)` | Date |\n\n| Argument | Type | Details |\n|----------|--------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------|\n| `date` | ComputedObject\\|Date\\|Number\\|String | The date to convert, one of: a number (number of milliseconds since the epoch), an ISO Date string, a JavaScript Date or a ComputedObject. |\n| `tz` | String, optional | An optional timezone only to be used with a string date. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// Numeric inputs are interpreted as milliseconds from Unix epoch.\nprint(ee.Date(0)); // Date (1970-01-01 00:00:00)\n\n// Scale factors can make numerical inputs more readable (e.g. 60 seconds).\nprint(ee.Date(60 * 1000)); // Date (1970-01-01 00:01:00)\n\n// ISO 8601 date string input examples.\nprint(ee.Date('2020')); // Date (2020-01-01 00:00:00)\nprint(ee.Date('2017-6-24')); // Date (2017-06-24 00:00:00)\nprint(ee.Date('2017-06-24')); // Date (2017-06-24 00:00:00)\nprint(ee.Date('2017-6-24T00:14:46')); // Date (2017-06-24 00:14:46)\nprint(ee.Date('2017-06-24T23:59:59')); // Date (2017-06-24 23:59:59)\n\n// With an optional time zone.\nprint(ee.Date('2020', 'US/Mountain')); // Date (2020-01-01T07:00:00)\n\n// Convert JavaScript now to Earth Engine Date\nprint(ee.Date(Date.now()));\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\nfrom datetime import datetime\n\n# Numeric inputs are interpreted as milliseconds from Unix epoch.\nprint(ee.Date(0).format().getInfo()) # 1970-01-01T00:00:00\n\n# Scale factors can make numerical inputs more readable (e.g. 60 seconds).\nprint(ee.Date(60 * 1000).format().getInfo()) # 1970-01-01T00:01:00\n\n# ISO 8601 date string input examples.\nprint(ee.Date('2020').format().getInfo()) # 2020-01-01T00:00:00\nprint(ee.Date('2017-6-24').format().getInfo()) # 2017-06-24T00:00:00\nprint(ee.Date('2017-06-24').format().getInfo()) # 2017-06-24T00:00:00\nprint(ee.Date('2017-6-24T00:14:46').format().getInfo()) # 2017-06-24T00:14:46\nprint(ee.Date('2017-06-24T23:59:59').format().getInfo()) # 2017-06-24T23:59:59\n\n# With an optional time zone.\nprint(ee.Date('2020', 'US/Mountain').format().getInfo()) # 2020-01-01T07:00:00\n\n# Convert Python datetime.now() to Earth Engine Date\nprint(ee.Date(datetime.now()).format().getInfo())\n```"]]