ee.Date.unitRatio
Returns the ratio of the length of one unit to the length of another, e.g., unitRatio('day', 'minute') returns 1440. Valid units are 'year', 'month' 'week', 'day', 'hour', 'minute', and 'second'.
Usage | Returns |
---|
ee.Date.unitRatio(numerator, denominator) | Float |
Argument | Type | Details |
---|
numerator | String | |
denominator | String | |
Examples
print('Minutes in a day', ee.Date.unitRatio('day', 'minute'));
print('Seconds in a year', ee.Date.unitRatio('year', 'second'));
print('Years in a month', ee.Date.unitRatio('month', 'year'));
print('Hours in a week', ee.Date.unitRatio('week', 'hour'));
Python setup
See the
Python Environment page for information on the Python API and using
geemap
for interactive development.
import ee
import geemap.core as geemap
display('Minutes in a day:', ee.Date.unitRatio('day', 'minute'))
display('Seconds in a year:', ee.Date.unitRatio('year', 'second'))
display('Years in a month:', ee.Date.unitRatio('month', 'year'))
display('Hours in a week:', ee.Date.unitRatio('week', 'hour'))
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-13 UTC.
[null,null,["Last updated 2024-07-13 UTC."],[[["`ee.Date.unitRatio()` calculates the length ratio between two time units, such as days and minutes."],["Valid time units for this function include 'year', 'month', 'week', 'day', 'hour', 'minute', and 'second'."],["The function takes two string arguments: the numerator unit and the denominator unit, and returns a float representing the ratio."],["Example: `ee.Date.unitRatio('day', 'minute')` would return 1440, indicating there are 1440 minutes in a day."]]],["The `unitRatio` function calculates the ratio between two time units. It accepts two string arguments: `numerator` and `denominator`, representing the desired units. Valid time units include 'year', 'month', 'week', 'day', 'hour', 'minute', and 'second'. The function returns a float value representing the ratio of the numerator to the denominator (e.g., how many minutes are in a day). Examples are provided in JavaScript and Python demonstrating various unit conversions.\n"]]