ee.Date.advance

在指定日期中新增指定單位,建立新的日期。

用量傳回
Date.advance(delta, unit, timeZone)日期
引數類型詳細資料
this:date日期
delta浮點值
unit字串可以是「year」、「month」、「week」、「day」、「hour」、「minute」或「second」。
timeZone字串,預設值:空值時區 (例如'America/Los_Angeles');預設為世界標準時間。

範例

程式碼編輯器 (JavaScript)

// Defines a base date/time for the following examples.
var BASE_DATE = ee.Date('2020-7-1T13:00', 'UTC');
print(BASE_DATE, 'The base date/time');

// Demonstrates basic usage.
print(BASE_DATE.advance(1, 'week'), '+1 week');
print(BASE_DATE.advance(2, 'years'), '+2 years');

// Demonstrates that negative delta moves back in time.
print(BASE_DATE.advance(-1, 'second'), '-1 second');

Python 設定

請參閱「 Python 環境」頁面,瞭解 Python API 和如何使用 geemap 進行互動式開發。

import ee
import geemap.core as geemap

Colab (Python)

# Defines a base date/time for the following examples.
BASE_DATE = ee.Date('2020-01-01T00:00', 'UTC')
display('The base date/time', BASE_DATE)

# Demonstrates basic usage.
display('+1 week', BASE_DATE.advance(1, 'week'))
display('+2 years', BASE_DATE.advance(2, 'years'))

# Demonstrates that negative delta moves back in time.
display('-1 second', BASE_DATE.advance(-1, 'second'))