टाइमस्टैंप फ़ंक्शन
| नाम | ब्यौरा |
CURRENT_TIMESTAMP
|
अनुरोध के समय के हिसाब से TIMESTAMP जनरेट करता है.
|
TIMESTAMP_TRUNC
|
यह फ़ंक्शन, किसी TIMESTAMP को दिए गए लेवल के मुताबिक बदल देता है.
|
UNIX_MICROS_TO_TIMESTAMP
|
यह फ़ंक्शन, 1970-01-01 00:00:00 UTC के बाद से अब तक के माइक्रोसेकंड की संख्या को TIMESTAMP में बदलता है
|
UNIX_MILLIS_TO_TIMESTAMP
|
1970-01-01 00:00:00 UTC के बाद से मिलेसेकंड की संख्या को TIMESTAMP में बदलता है
|
UNIX_SECONDS_TO_TIMESTAMP
|
1970-01-01 00:00:00 UTC के बाद से गुज़रे सेकंड की संख्या को TIMESTAMP में बदलता है
|
TIMESTAMP_ADD
|
यह फ़ंक्शन, TIMESTAMP में समयावधि जोड़ता है
|
TIMESTAMP_SUB
|
यह फ़ंक्शन, TIMESTAMP में से समयावधि घटाता है
|
TIMESTAMP_TO_UNIX_MICROS
|
यह TIMESTAMP को 1970-01-01 00:00:00 UTC के बाद से अब तक के माइक्रोसेकंड की संख्या में बदलता है
|
TIMESTAMP_TO_UNIX_MILLIS
|
यह TIMESTAMP को 1970-01-01 00:00:00 UTC के बाद से अब तक के मिलीसेकंड की संख्या में बदलता है
|
TIMESTAMP_TO_UNIX_SECONDS
|
यह TIMESTAMP को 1970-01-01 00:00:00 UTC के बाद से सेकंड की संख्या में बदलता है
|
CURRENT_TIMESTAMP
सिंटैक्स:
current_timestamp() -> TIMESTAMP
ब्यौरा:
अनुरोध के समय input की शुरुआत में टाइमस्टैंप मिलता है. इसे 1970-01-01 00:00:00 UTC के बाद से माइक्रोसेकंड की संख्या के तौर पर समझा जाता है.
यह क्वेरी में स्थिर होता है. इसे एक से ज़्यादा बार कॉल करने पर, हमेशा एक ही वैल्यू मिलती है.
TIMESTAMP_TRUNC
सिंटैक्स:
timestamp_trunc(timestamp: TIMESTAMP, granularity: STRING[, timezone: STRING]) -> TIMESTAMP
ब्यौरा:
यह फ़ंक्शन, टाइमस्टैंप को दिए गए लेवल के मुताबिक बदल देता है.
granularity आर्ग्युमेंट एक स्ट्रिंग होना चाहिए और इनमें से कोई एक होना चाहिए:
microsecondmillisecondsecondminutehourdayweekweek([weekday])monthquarteryearisoyear
अगर timezone आर्ग्युमेंट दिया गया है, तो ट्रंकेट करने की प्रोसेस, दिए गए टाइमज़ोन के कैलेंडर की सीमाओं के हिसाब से होगी. उदाहरण के लिए, दिन के हिसाब से ट्रंकेट करने पर, दिए गए टाइमज़ोन के हिसाब से रात 12 बजे का समय दिखेगा. समय को छोटा करते समय, डेलाइट सेविंग टाइम का ध्यान रखा जाएगा.
अगर timezone नहीं दिया गया है, तो कैलेंडर की UTC सीमाओं के आधार पर काटा जाएगा.
timezone आर्ग्युमेंट, tz डेटाबेस से किसी टाइमज़ोन का स्ट्रिंग फ़ॉर्मैट होना चाहिए. उदाहरण के लिए, America/New_York. GMT से ऑफ़सेट तय करके, कस्टम टाइम ऑफ़सेट का भी इस्तेमाल किया जा सकता है.
उदाहरण:
timestamp |
granularity |
timezone |
timestamp_trunc(timestamp, granularity, timezone) |
|---|---|---|---|
| 2000-01-01 10:20:30:123456 यूटीसी | "second" | नहीं दिया गया | 2001-01-01 10:20:30 यूटीसी |
| 31-05-1997 04:30:30 यूटीसी | "day" | नहीं दिया गया | 1997-05-31 00:00:00 यूटीसी |
| 31-05-1997 04:30:30 यूटीसी | "day" | "America/Los_Angeles" | 1997-05-30 07:00:00 यूटीसी |
| 2001-03-16 04:00:00 यूटीसी | "week(friday) | नहीं दिया गया | 16-03-2001 00:00:00 यूटीसी |
| 23-03-2001 04:00:00 यूटीसी | "week(friday) | "America/Los_Angeles" | 23-03-2001 17:00:00 यूटीसी |
| 2026-01-24 20:00:00 यूटीसी | "महीना" | "GMT+06:32:43" | 2026-01-01T06:32:43 यूटीसी |
UNIX_MICROS_TO_TIMESTAMP
सिंटैक्स:
unix_micros_to_timestamp(input: INT64) -> TIMESTAMP
ब्यौरा:
यह input (1970-01-01 00:00:00 UTC के बाद के माइक्रोसेकंड की संख्या के तौर पर इंटरप्रेट किया जाता है) को TIMESTAMP में बदलता है. अगर input को मान्य TIMESTAMP में नहीं बदला जा सकता, तो error दिखाता है.
उदाहरण:
input |
unix_micros_to_timestamp(input) |
|---|---|
| 0L | 1970-01-01 00:00:00 यूटीसी |
| 400123456L | 1970-01-01 00:06:40.123456 यूटीसी |
| -1000000L | 1969-12-31 23:59:59 यूटीसी |
Web
const result = await execute(db.pipeline() .collection("documents") .select( field("createdAtMicros").unixMicrosToTimestamp().as("createdAtString") ) );
Swift
let result = try await db.pipeline() .collection("documents") .select([ Field("createdAtMicros").unixMicrosToTimestamp().as("createdAtString") ]) .execute()
Kotlin
val result = db.pipeline() .collection("documents") .select( field("createdAtMicros").unixMicrosToTimestamp().alias("createdAtString") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("documents") .select( field("createdAtMicros").unixMicrosToTimestamp().alias("createdAtString") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("documents") .select( Field.of("createdAtMicros") .unix_micros_to_timestamp() .as_("createdAtString") ) .execute() )
UNIX_MILLIS_TO_TIMESTAMP
सिंटैक्स:
unix_millis_to_timestamp(input: INT64) -> TIMESTAMP
ब्यौरा:
यह फ़ंक्शन, input (जिसे 1970-01-01 00:00:00 UTC के बाद के मिलीसेकंड की संख्या के तौर पर इंटरप्रेट किया जाता है) को TIMESTAMP में बदलता है. अगर input को मान्य TIMESTAMP में नहीं बदला जा सकता, तो error दिखाता है.
उदाहरण:
input |
unix_millis_to_timestamp(input) |
|---|---|
| 0L | 1970-01-01 00:00:00 यूटीसी |
| 4000123L | 1970-01-01 01:06:40.123 यूटीसी |
| -1000000L | 1969-12-31 23:43:20 यूटीसी |
Web
const result = await execute(db.pipeline() .collection("documents") .select( field("createdAtMillis").unixMillisToTimestamp().as("createdAtString") ) );
Swift
let result = try await db.pipeline() .collection("documents") .select([ Field("createdAtMillis").unixMillisToTimestamp().as("createdAtString") ]) .execute()
Kotlin
val result = db.pipeline() .collection("documents") .select( field("createdAtMillis").unixMillisToTimestamp().alias("createdAtString") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("documents") .select( field("createdAtMillis").unixMillisToTimestamp().alias("createdAtString") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("documents") .select( Field.of("createdAtMillis") .unix_millis_to_timestamp() .as_("createdAtString") ) .execute() )
UNIX_SECONDS_TO_TIMESTAMP
सिंटैक्स:
unix_seconds_to_timestamp(input: INT64) -> TIMESTAMP
ब्यौरा:
यह input (जिसे 1970-01-01 00:00:00 UTC के बाद के सेकंड की संख्या के तौर पर इंटरप्रेट किया जाता है) को TIMESTAMP में बदलता है. अगर input को मान्य TIMESTAMP में नहीं बदला जा सकता, तो error दिखाता है.
उदाहरण:
input |
unix_seconds_to_timestamp(input) |
|---|---|
| 0L | 1970-01-01 00:00:00 यूटीसी |
| 60L | 1970-01-01 00:01:00 यूटीसी |
| -300L | 1969-12-31 23:55:00 यूटीसी |
Web
const result = await execute(db.pipeline() .collection("documents") .select( field("createdAtSeconds").unixSecondsToTimestamp().as("createdAtString") ) );
Swift
let result = try await db.pipeline() .collection("documents") .select([ Field("createdAtSeconds").unixSecondsToTimestamp().as("createdAtString") ]) .execute()
Kotlin
val result = db.pipeline() .collection("documents") .select( field("createdAtSeconds").unixSecondsToTimestamp().alias("createdAtString") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("documents") .select( field("createdAtSeconds").unixSecondsToTimestamp().alias("createdAtString") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("documents") .select( Field.of("createdAtSeconds") .unix_seconds_to_timestamp() .as_("createdAtString") ) .execute() )
TIMESTAMP_ADD
सिंटैक्स:
timestamp_add(timestamp: TIMESTAMP, unit: STRING, amount: INT64) -> TIMESTAMP
ब्यौरा:
timestamp से unit का amount जोड़ता है. amount आर्ग्युमेंट नेगेटिव हो सकता है. इस मामले में, यह TIMESTAMP_SUB के बराबर होता है.
unit आर्ग्युमेंट एक स्ट्रिंग होना चाहिए और इनमें से कोई एक होना चाहिए:
microsecondmillisecondsecondminutehourday
अगर टाइमस्टैंप, TIMESTAMP रेंज में नहीं आता है, तो यह फ़ंक्शन गड़बड़ी दिखाता है.
उदाहरण:
timestamp |
unit |
amount |
timestamp_add(timestamp, unit, amount) |
|---|---|---|---|
| 2025-02-20 00:00:00 यूटीसी | "minute" | 2L | 2025-02-20 00:02:00 यूटीसी |
| 2025-02-20 00:00:00 यूटीसी | "घंटा" | -4L | 2025-02-19 20:00:00 यूटीसी |
| 2025-02-20 00:00:00 यूटीसी | "day" | 500000 | 2025-02-25 00:00:00 यूटीसी |
Web
const result = await execute(db.pipeline() .collection("documents") .select( field("createdAt").timestampAdd("day", 3653).as("expiresAt") ) );
Swift
let result = try await db.pipeline() .collection("documents") .select([ Field("createdAt").timestampAdd(3653, .day).as("expiresAt") ]) .execute()
Kotlin
val result = db.pipeline() .collection("documents") .select( field("createdAt") .timestampAdd("day", 3653) .alias("expiresAt") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("documents") .select( field("createdAt").timestampAdd("day", 3653).alias("expiresAt") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("documents") .select(Field.of("createdAt").timestamp_add("day", 3653).as_("expiresAt")) .execute() )
TIMESTAMP_SUB
सिंटैक्स:
timestamp_sub(timestamp: TIMESTAMP, unit: STRING, amount: INT64) -> TIMESTAMP
ब्यौरा:
timestamp में से unit का amount घटाता है. amount आर्ग्युमेंट की वैल्यू नेगेटिव हो सकती है. इस मामले में, यह TIMESTAMP_ADD के बराबर होता है.
unit आर्ग्युमेंट एक स्ट्रिंग होना चाहिए और इनमें से कोई एक होना चाहिए:
microsecondmillisecondsecondminutehourday
अगर टाइमस्टैंप, TIMESTAMP रेंज में नहीं आता है, तो यह फ़ंक्शन गड़बड़ी दिखाता है.
उदाहरण:
timestamp |
unit |
amount |
timestamp_sub(timestamp, unit, amount) |
|---|---|---|---|
| 04-07-2026 00:00:00 यूटीसी | "minute" | 40L | 2026-07-03 23:20:00 यूटीसी |
| 04-07-2026 00:00:00 यूटीसी | "घंटा" | -24L | 05-07-2026 00:00:00 यूटीसी |
| 04-07-2026 00:00:00 यूटीसी | "day" | 3L | 01-07-2026 00:00:00 यूटीसी |
Web
const result = await execute(db.pipeline() .collection("documents") .select( field("expiresAt").timestampSubtract("day", 14).as("sendWarningTimestamp") ) );
Swift
let result = try await db.pipeline() .collection("documents") .select([ Field("expiresAt").timestampSubtract(14, .day).as("sendWarningTimestamp") ]) .execute()
Kotlin
val result = db.pipeline() .collection("documents") .select( field("expiresAt") .timestampSubtract("day", 14) .alias("sendWarningTimestamp") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("documents") .select( field("expiresAt").timestampSubtract("day", 14).alias("sendWarningTimestamp") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("documents") .select( Field.of("expiresAt") .timestamp_subtract("day", 14) .as_("sendWarningTimestamp") ) .execute() )
TIMESTAMP_TO_UNIX_MICROS
सिंटैक्स:
timestamp_to_unix_micros(input: TIMESTAMP) -> INT64
ब्यौरा:
यह input को 1970-01-01 00:00:00 UTC के बाद से अब तक के माइक्रोसेकंड की संख्या में बदलता है. यह फ़ंक्शन, ज़्यादा सटीक वैल्यू को छोटा करता है. इसके लिए, यह वैल्यू को माइक्रोसेकंड की शुरुआत में राउंड डाउन करता है.
उदाहरण:
input |
timestamp_to_unix_micros(input) |
|---|---|
| 1970-01-01 00:00:00 यूटीसी | 0L |
| 1970-01-01 00:06:40.123456 यूटीसी | 400123456L |
| 1969-12-31 23:59:59 यूटीसी | -1000000L |
Web
const result = await execute(db.pipeline() .collection("documents") .select( field("dateString").timestampToUnixMicros().as("unixMicros") ) );
Swift
let result = try await db.pipeline() .collection("documents") .select([ Field("dateString").timestampToUnixMicros().as("unixMicros") ]) .execute()
Kotlin
val result = db.pipeline() .collection("documents") .select( field("dateString").timestampToUnixMicros().alias("unixMicros") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("documents") .select( field("dateString").timestampToUnixMicros().alias("unixMicros") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("documents") .select(Field.of("dateString").timestamp_to_unix_micros().as_("unixMicros")) .execute() )
TIMESTAMP_TO_UNIX_MILLIS
सिंटैक्स:
timestamp_to_unix_millis(input: TIMESTAMP) -> INT64
ब्यौरा:
यह input को 1970-01-01 00:00:00 UTC के बाद से मिलीसेकंड की संख्या में बदलता है. यह फ़ंक्शन, मिलीसेकंड की शुरुआत में राउंड डाउन करके, ज़्यादा सटीक वैल्यू को छोटा करता है.
उदाहरण:
input |
timestamp_to_unix_millis(input) |
|---|---|
| 1970-01-01 00:00:00 यूटीसी | 0L |
| 1970-01-01 01:06:40.123 यूटीसी | 4000123L |
| 1969-12-31 23:43:20 | -1000000L |
Web
const result = await execute(db.pipeline() .collection("documents") .select( field("dateString").timestampToUnixMillis().as("unixMillis") ) );
Swift
let result = try await db.pipeline() .collection("documents") .select([ Field("dateString").timestampToUnixMillis().as("unixMillis") ]) .execute()
Kotlin
val result = db.pipeline() .collection("documents") .select( field("dateString").timestampToUnixMillis().alias("unixMillis") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("documents") .select( field("dateString").timestampToUnixMillis().alias("unixMillis") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("documents") .select(Field.of("dateString").timestamp_to_unix_millis().as_("unixMillis")) .execute() )
TIMESTAMP_TO_UNIX_SECONDS
सिंटैक्स:
timestamp_to_unix_seconds(input: TIMESTAMP) -> INT64
ब्यौरा:
यह फ़ंक्शन, input को 1970-01-01 00:00:00 UTC के बाद से गुज़रे सेकंड की संख्या में बदलता है. यह फ़ंक्शन, सेकंड की शुरुआत में राउंड डाउन करके, ज़्यादा सटीक वैल्यू को छोटा करता है.
उदाहरण:
input |
timestamp_to_unix_seconds(input) |
|---|---|
| 1970-01-01 00:00:00 यूटीसी | 0L |
| 1970-01-01 00:01:00 यूटीसी | 60L |
| 1969-12-31 23:55:00 यूटीसी | -300L |
Web
const result = await execute(db.pipeline() .collection("documents") .select( field("dateString").timestampToUnixSeconds().as("unixSeconds") ) );
Swift
let result = try await db.pipeline() .collection("documents") .select([ Field("dateString").timestampToUnixSeconds().as("unixSeconds") ]) .execute()
Kotlin
val result = db.pipeline() .collection("documents") .select( field("dateString").timestampToUnixSeconds().alias("unixSeconds") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("documents") .select( field("dateString").timestampToUnixSeconds().alias("unixSeconds") ) .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("documents") .select(Field.of("dateString").timestamp_to_unix_seconds().as_("unixSeconds")) .execute() )