Returns this date's elapsed fraction of the specified unit (between 0 and 1).
Usage
Returns
Date.getFraction(unit, timeZone)
Float
Argument
Type
Details
this: date
Date
unit
String
One of 'year', 'month' 'week', 'day', 'hour', 'minute', or 'second'.
timeZone
String, default: null
The time zone (e.g. 'America/Los_Angeles'); defaults to UTC.
Examples
Code Editor (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'));