ee.Date.getFraction

แสดงผลเศษส่วนของหน่วยที่ระบุซึ่งผ่านไปแล้วของวันที่นี้ (ระหว่าง 0 ถึง 1)

การใช้งานการคืนสินค้า
Date.getFraction(unit, timeZone)ทศนิยม
อาร์กิวเมนต์ประเภทรายละเอียด
this: dateวันที่
unitสตริงโดยอาจเป็น "ปี", "เดือน", "สัปดาห์", "วัน", "ชั่วโมง", "นาที" หรือ "วินาที"
timeZoneสตริง ค่าเริ่มต้น: nullเขตเวลา (เช่น 'America/Los_Angeles'); เริ่มต้นเป็น UTC

ตัวอย่าง

เครื่องมือแก้ไขโค้ด (JavaScript)

var date = ee.Date('2021-4-30T07:15:31.24');

print('Elapsed fraction of a year', date.getFraction('year'));
print('Elapsed fraction of a month', date.getFraction('month'));
print('Elapsed fraction of a week', date.getFraction('week'));
print('Elapsed fraction of a day', date.getFraction('day'));
print('Elapsed fraction of an hour', date.getFraction('hour'));
print('Elapsed fraction of a minute', date.getFraction('minute'));
print('Elapsed fraction of a second', date.getFraction('second'));

การตั้งค่า Python

ดูข้อมูลเกี่ยวกับ Python API และการใช้ geemap สําหรับการพัฒนาแบบอินเทอร์แอกทีฟได้ที่หน้า สภาพแวดล้อม Python

import ee
import geemap.core as geemap

Colab (Python)

date = ee.Date('2021-4-30T07:15:31.24')

display('Elapsed fraction of a year:', date.getFraction('year'))
display('Elapsed fraction of a month:', date.getFraction('month'))
display('Elapsed fraction of a week:', date.getFraction('week'))
display('Elapsed fraction of a day:', date.getFraction('day'))
display('Elapsed fraction of an hour:', date.getFraction('hour'))
display('Elapsed fraction of a minute:', date.getFraction('minute'))
display('Elapsed fraction of a second:', date.getFraction('second'))