ee.Date.getFraction
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
यह फ़ंक्शन, तारीख के बीत चुके समय को किसी तय यूनिट में दिखाता है. यह यूनिट 0 से 1 के बीच की होनी चाहिए.
इस्तेमाल | रिटर्न |
---|
Date.getFraction(unit, timeZone) | फ़्लोट |
आर्ग्यूमेंट | टाइप | विवरण |
---|
यह: date | तारीख | |
unit | स्ट्रिंग | 'साल', 'महीना', 'हफ़्ता', 'दिन', 'घंटा', 'मिनट' या 'सेकंड' में से कोई एक. |
timeZone | स्ट्रिंग, डिफ़ॉल्ट: null | टाइम ज़ोन (उदाहरण के लिए, 'America/Los_Angeles'); डिफ़ॉल्ट रूप से यूटीसी पर सेट होता है. |
उदाहरण
कोड एडिटर (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'))
जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2025-07-25 (UTC) को अपडेट किया गया.
[null,null,["आखिरी बार 2025-07-25 (UTC) को अपडेट किया गया."],[[["\u003cp\u003e\u003ccode\u003eDate.getFraction()\u003c/code\u003e calculates the elapsed fraction of a specified time unit (year, month, week, day, hour, minute, or second) for a given date, returning a value between 0 and 1.\u003c/p\u003e\n"],["\u003cp\u003eThe function takes the date, the desired time unit, and an optional time zone as input (defaulting to UTC if not specified).\u003c/p\u003e\n"],["\u003cp\u003eThe returned value represents the proportion of the specified time unit that has passed for the given date, for instance, 0.5 for 'day' would indicate it's midday.\u003c/p\u003e\n"],["\u003cp\u003eThis function is valuable for tasks like determining the progress through a specific time period, such as calculating the fraction of a year that has elapsed.\u003c/p\u003e\n"]]],[],null,["# ee.Date.getFraction\n\nReturns this date's elapsed fraction of the specified unit (between 0 and 1).\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|----------------------------------------|---------|\n| Date.getFraction`(unit, `*timeZone*`)` | Float |\n\n| Argument | Type | Details |\n|--------------|-----------------------|-----------------------------------------------------------------------|\n| this: `date` | Date | |\n| `unit` | String | One of 'year', 'month', 'week', 'day', 'hour', 'minute', or 'second'. |\n| `timeZone` | String, default: null | The time zone (e.g., 'America/Los_Angeles'); defaults to UTC. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\nvar date = ee.Date('2021-4-30T07:15:31.24');\n\nprint('Elapsed fraction of a year', date.getFraction('year'));\nprint('Elapsed fraction of a month', date.getFraction('month'));\nprint('Elapsed fraction of a week', date.getFraction('week'));\nprint('Elapsed fraction of a day', date.getFraction('day'));\nprint('Elapsed fraction of an hour', date.getFraction('hour'));\nprint('Elapsed fraction of a minute', date.getFraction('minute'));\nprint('Elapsed fraction of a second', date.getFraction('second'));\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\ndate = ee.Date('2021-4-30T07:15:31.24')\n\ndisplay('Elapsed fraction of a year:', date.getFraction('year'))\ndisplay('Elapsed fraction of a month:', date.getFraction('month'))\ndisplay('Elapsed fraction of a week:', date.getFraction('week'))\ndisplay('Elapsed fraction of a day:', date.getFraction('day'))\ndisplay('Elapsed fraction of an hour:', date.getFraction('hour'))\ndisplay('Elapsed fraction of a minute:', date.getFraction('minute'))\ndisplay('Elapsed fraction of a second:', date.getFraction('second'))\n```"]]