The maxTimestamp utility function efficiently identifies the most recent timestamp from an array of Firestore timestamps. This tool is particularly useful in scenarios where determining the latest event or update time is essential.
In applications where time tracking is crucial, such as logging events or updates, identifying the latest timestamp is a common requirement. The maxTimestamp function simplifies this task by evaluating an array of Firestore Timestamps and returning the most recent one.
Import `maxTimestamp` and use it to find the latest timestamp from an array:typescriptimport { firestore } from 'firebase-admin'import { maxTimestamp } from 'path-to-your-utilities'// Example array of Firestore timestampsconst timestamps: PossiblyMissing<firestore.Timestamp>[] = [ firestore.Timestamp.now(), null, firestore.Timestamp.fromDate(new Date('2020-01-01')), // More timestamps]
Invoke maxTimestamp with the array of timestamps to identify the most recent:
// Determine the latest timestampconst latestTimestamp = maxTimestamp(timestamps)// 'latestTimestamp' will be the most recent timestamp, or undefined if all values are missing or the array is empty
maxTimestamp is designed to return undefined when faced with an array that is either empty or contains only missing (null/undefined) timestamps, enabling seamless handling of such scenarios.
Use maxTimestamp when you need to determine the most recent event or data update timestamp in your application.
Ensure that the array of timestamps is accurately populated to avoid incorrect evaluations.
Consider the implications of time zones and clock skew when working with timestamps from different sources.
Timestamp comparisons can be impacted by time zone differences and clock
synchronization issues. Ensure that all timestamps are comparable and sourced
reliably.
{"docsConfig":{"$schema":"https://mintlify.com/docs.json","theme":"mint","name":"Firebridge","colors":{"primary":"#36656B","light":"#DAF1F4","dark":"#36656B"},"favicon":"/favicon.svg","logo":{"light":"https://mintcdn.com/humancollective/oNaxoG7QbCmsD9Gt/logo/light.svg?fit=max\u0026auto=format\u0026n=oNaxoG7QbCmsD9Gt\u0026q=85\u0026s=19a786e3b49034489f469d223f640a91","dark":"https://mintcdn.com/humancollective/oNaxoG7QbCmsD9Gt/logo/dark.svg?fit=max\u0026auto=format\u0026n=oNaxoG7QbCmsD9Gt\u0026q=85\u0026s=5ab41e88ab90b2cf7147044fcf65c387"},"background":{"decoration":null,"color":{"light":"#f3f8f8","dark":"#1e2a2e"}},"navbar":{"primary":{"type":"button","label":"Github","href":"https://github.com/firebridgekit/Firebridge"}},"footer":{"socials":{"github":"https://github.com/firebridgekit/Firebridge"}},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"humancollective","hasAudioNarration":false,"actualSubdomain":"humancollective","customDomains":["firebridge.dev"],"gitSource":{"type":"github","owner":"firebridgekit","repo":"firebridge","deployBranch":"main","contentDirectory":"docs","isPrivate":false,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6a21a6025634a55fb597136b","collectionId":"35ec6246-3e30-4bc4-b309-ee939fc07198","schemaVersion":"v2"},"entitlements":{},"buildId":"6a21a6025634a55fb597136b:success","clientVersion":"0.0.4021","searchFilterCounts":[{"language":"default","tag":"Cloud","count":26},{"language":"default","tag":"Actions","count":7},{"language":"default","tag":"Timestamps","count":6},{"language":"default","tag":"Metrics","count":5},{"language":"default","tag":"React","count":4},{"language":"default","tag":"Snapshots","count":3},{"language":"default","tag":"Hooks","count":3},{"language":"default","tag":"Execution","count":2},{"language":"default","tag":"Invokeables","count":2},{"language":"default","tag":"Introduction","count":2}]},"assistantConfig":{},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"per-site-search-delta","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-private-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"byok-sep-25","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-updated-9-15","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[],"page":{"pagePath":"cloud/timestamps/maxTimestamp","slug":"/cloud/timestamps/maxTimestamp","pageMetadata":{"title":"maxTimestamp","description":"The `maxTimestamp` utility function efficiently identifies the most recent timestamp from an array of Firestore timestamps. This tool is particularly useful in scenarios where determining the latest event or update time is essential.","icon":"code","href":"/cloud/timestamps/maxTimestamp"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx, jsxs: _jsxs} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n code: \"code\",\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsxs(_components.p, {\n children: [\"The \", _jsx(_components.code, {\n children: \"maxTimestamp\"\n }), \" utility function efficiently identifies the most recent timestamp from an array of Firestore timestamps. This tool is particularly useful in scenarios where determining the latest event or update time is essential.\"]\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={code:`code`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(Heading,{level:`2`,id:`introduction`,children:`Introduction`}),`\n`,_jsxs(_components.p,{children:[`In applications where time tracking is crucial, such as logging events or updates, identifying the latest timestamp is a common requirement. The `,_jsx(_components.code,{children:`maxTimestamp`}),` function simplifies this task by evaluating an array of Firestore Timestamps and returning the most recent one.`]}),`\n`,_jsx(Heading,{level:`3`,id:`key-features`,children:`Key Features`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Latest Timestamp Identification`}),`: Extracts the most recent timestamp from an array of Firestore Timestamps.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Handles Missing Values`}),`: Skips over `,_jsx(_components.code,{children:`null`}),` or `,_jsx(_components.code,{children:`undefined`}),` values to focus on valid timestamps.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Robust and Efficient`}),`: Utilizes efficient sorting to determine the latest timestamp quickly.`]}),`\n`]}),`\n`,_jsx(Heading,{level:`3`,id:`utilization`,children:`Utilization`}),`\n`,_jsx(Heading,{level:`4`,id:`preparing-timestamps-for-evaluation`,children:`Preparing Timestamps for Evaluation`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`13`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`13`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`Import`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\" `maxTimestamp`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` and`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` use`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` it`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` to`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` find`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` the`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` latest`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` timestamp`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` an`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#C8C8C8`},children:` array`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`typescript`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`firestore`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'firebase-admin'`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`maxTimestamp`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'path-to-your-utilities'`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Example array of Firestore timestamps`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` timestamps`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` PossiblyMissing`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`firestore`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Timestamp`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`>[] `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` firestore`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`Timestamp`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`now`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` null`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` firestore`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`Timestamp`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`fromDate`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`new`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` Date`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'2020-01-01'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)),`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // More timestamps`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`4`,id:`finding-the-latest-timestamp`,children:`Finding the Latest Timestamp`}),`\n`,_jsxs(_components.p,{children:[`Invoke `,_jsx(_components.code,{children:`maxTimestamp`}),` with the array of timestamps to identify the most recent:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`4`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`4`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Determine the latest timestamp`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` latestTimestamp`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` maxTimestamp`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`timestamps`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// 'latestTimestamp' will be the most recent timestamp, or undefined if all values are missing or the array is empty`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`handling-arrays-with-missing-or-no-timestamps`,children:`Handling Arrays with Missing or No Timestamps`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`maxTimestamp`}),` is designed to return `,_jsx(_components.code,{children:`undefined`}),` when faced with an array that is either empty or contains only missing (null/undefined) timestamps, enabling seamless handling of such scenarios.`]}),`\n`,_jsx(Heading,{level:`2`,id:`best-practices`,children:`Best Practices`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`Use `,_jsx(_components.code,{children:`maxTimestamp`}),` when you need to determine the most recent event or data update timestamp in your application.`]}),`\n`,_jsx(_components.li,{children:`Ensure that the array of timestamps is accurately populated to avoid incorrect evaluations.`}),`\n`,_jsx(_components.li,{children:`Consider the implications of time zones and clock skew when working with timestamps from different sources.`}),`\n`]}),`\n`,_jsx(Warning,{children:_jsx(_components.p,{children:`Timestamp comparisons can be impacted by time zone differences and clock\nsynchronization issues. Ensure that all timestamps are comparable and sourced\nreliably.`})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"maxTimestamp","description":"The `maxTimestamp` utility function efficiently identifies the most recent timestamp from an array of Firestore timestamps. This tool is particularly useful in scenarios where determining the latest event or update time is essential.","icon":"code","href":"/cloud/timestamps/maxTimestamp"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Introduction","slug":"introduction","depth":2,"children":[{"title":"Key Features","slug":"key-features","depth":3,"children":[]},{"title":"Utilization","slug":"utilization","depth":3,"children":[]},{"title":"Preparing Timestamps for Evaluation","slug":"preparing-timestamps-for-evaluation","depth":4,"children":[]},{"title":"Finding the Latest Timestamp","slug":"finding-the-latest-timestamp","depth":4,"children":[]}]},{"title":"Handling Arrays with Missing or No Timestamps","slug":"handling-arrays-with-missing-or-no-timestamps","depth":2,"children":[]},{"title":"Best Practices","slug":"best-practices","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"humancollective","siteName":"Firebridge","title":"maxTimestamp - Firebridge","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-01-07T00:45:36.608Z","originalFileLocation":"cloud/timestamps/maxTimestamp.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"The maxTimestamp utility function efficiently identifies the most recent timestamp from an array of Firestore timestamps. This tool is particularly useful in scenarios where determining the latest event or update time is essential.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Firebridge\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/humancollective/6f5gtnvP6iWrC6WE/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/humancollective/6f5gtnvP6iWrC6WE/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/humancollective/6f5gtnvP6iWrC6WE/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/humancollective/6f5gtnvP6iWrC6WE/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/humancollective/6f5gtnvP6iWrC6WE/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/humancollective/6f5gtnvP6iWrC6WE/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/humancollective/6f5gtnvP6iWrC6WE/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/humancollective/6f5gtnvP6iWrC6WE/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/humancollective/6f5gtnvP6iWrC6WE/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"maxTimestamp - Firebridge\">\u003cmeta data-mint-head property=\"og:description\" content=\"The maxTimestamp utility function efficiently identifies the most recent timestamp from an array of Firestore timestamps. This tool is particularly useful in scenarios where determining the latest event or update time is essential.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Firebridge\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://firebridge.dev/cloud/timestamps/maxTimestamp\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://humancollective.mintlify.app/_mintlify/api/og/v2?division=Timestamps\u0026amp;title=maxTimestamp\u0026amp;description=The+%60maxTimestamp%60+utility+function+efficiently+identifies+the+most+recent+timestamp+from+an+array+of+Firestore+timestamps.+This+tool+is+particularly+useful+in+\u0026amp;theme=494a5b55d5af8e2e45aa7d13\u0026amp;signature=d287748d65e255f9d94f65fe5ab97f431c5ebbb1ae0f66b5f88ee14e0c2e72e5\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"maxTimestamp - Firebridge\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"The maxTimestamp utility function efficiently identifies the most recent timestamp from an array of Firestore timestamps. This tool is particularly useful in scenarios where determining the latest event or update time is essential.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://humancollective.mintlify.app/_mintlify/api/og/v2?division=Timestamps\u0026amp;title=maxTimestamp\u0026amp;description=The+%60maxTimestamp%60+utility+function+efficiently+identifies+the+most+recent+timestamp+from+an+array+of+Firestore+timestamps.+This+tool+is+particularly+useful+in+\u0026amp;theme=494a5b55d5af8e2e45aa7d13\u0026amp;signature=d287748d65e255f9d94f65fe5ab97f431c5ebbb1ae0f66b5f88ee14e0c2e72e5\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/humancollective/6f5gtnvP6iWrC6WE/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Firebridge\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#36656B\">\u003clink data-mint-head rel=\"canonical\" href=\"https://firebridge.dev/cloud/timestamps/maxTimestamp\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/cloud/timestamps/maxTimestamp.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://firebridge.dev/#organization\",\"name\":\"Firebridge\",\"url\":\"https://firebridge.dev\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/humancollective/oNaxoG7QbCmsD9Gt/logo/light.svg?fit=max\u0026auto=format\u0026n=oNaxoG7QbCmsD9Gt\u0026q=85\u0026s=19a786e3b49034489f469d223f640a91\"}},{\"@type\":\"WebSite\",\"@id\":\"https://firebridge.dev#website\",\"name\":\"Firebridge\",\"url\":\"https://firebridge.dev\",\"publisher\":{\"@id\":\"https://firebridge.dev/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://firebridge.dev/cloud/timestamps/maxTimestamp#webpage\",\"url\":\"https://firebridge.dev/cloud/timestamps/maxTimestamp\",\"name\":\"maxTimestamp\",\"description\":\"The maxTimestamp utility function efficiently identifies the most recent timestamp from an array of Firestore timestamps. This tool is particularly useful in scenarios where determining the latest event or update time is essential.\",\"dateModified\":\"2026-01-07T00:45:36.608Z\",\"isPartOf\":{\"@id\":\"https://firebridge.dev#website\"},\"breadcrumb\":{\"@id\":\"https://firebridge.dev/cloud/timestamps/maxTimestamp#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://firebridge.dev/cloud/timestamps/maxTimestamp#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Cloud\",\"item\":\"https://firebridge.dev/cloud/cloud-installation\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"maxTimestamp\",\"item\":\"https://firebridge.dev/cloud/timestamps/maxTimestamp\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://firebridge.dev/cloud/timestamps/maxTimestamp#article\",\"headline\":\"maxTimestamp\",\"name\":\"maxTimestamp\",\"description\":\"The maxTimestamp utility function efficiently identifies the most recent timestamp from an array of Firestore timestamps. This tool is particularly useful in scenarios where determining the latest event or update time is essential.\",\"url\":\"https://firebridge.dev/cloud/timestamps/maxTimestamp\",\"mainEntityOfPage\":{\"@id\":\"https://firebridge.dev/cloud/timestamps/maxTimestamp#webpage\"},\"dateModified\":\"2026-01-07T00:45:36.608Z\",\"publisher\":{\"@id\":\"https://firebridge.dev/#organization\"},\"isPartOf\":{\"@id\":\"https://firebridge.dev#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Firebridge\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"Firebridge","nav":{"global":null,"groups":[{"group":"Introduction","pages":[{"title":"Why Firebridge?","href":"/introduction"},{"title":"Get Started","href":"/get-started"}]},{"group":"React","pages":[{"title":"React Installation","icon":"react","href":"/react/react-installation"},{"group":"Hooks","pages":[{"title":"useDocument","icon":"code","href":"/react/hooks/useDocument"},{"title":"useCollection","icon":"code","href":"/react/hooks/useCollection"},{"title":"useCallable","icon":"code","href":"/react/hooks/useCallable"}]}]},{"group":"Cloud","pages":[{"title":"Cloud Installation","icon":"cloud","href":"/cloud/cloud-installation"},{"group":"Invokeables","pages":[{"title":"Callables","icon":"code","href":"/cloud/invokeables/callable"},{"title":"Requestables","icon":"code","href":"/cloud/invokeables/requestable"}]},{"group":"Execution","pages":[{"title":"Batch Execution","icon":"code","href":"/cloud/execution/batch"},{"title":"Parallel Execution","icon":"code","href":"/cloud/execution/parallel"}]},{"group":"Actions","pages":[{"title":"Actions Overview","href":"/cloud/actions/actions-overview"},{"title":"firestoreAdd","icon":"code","href":"/cloud/actions/firestoreAdd"},{"title":"firestoreDelete","icon":"code","href":"/cloud/actions/firestoreDelete"},{"title":"firestoreGet","icon":"code","href":"/cloud/actions/firestoreGet"},{"title":"firestoreSet","icon":"code","href":"/cloud/actions/firestoreSet"},{"title":"firestoreUpdate","icon":"code","href":"/cloud/actions/firestoreUpdate"},{"title":"firestoreMerge","icon":"code","href":"/cloud/actions/firestoreMerge"}]},{"group":"Snapshots","pages":[{"title":"Change Types","icon":"code","href":"/cloud/snapshots/getChangeType"},{"title":"readSnapshot","icon":"code","href":"/cloud/snapshots/readSnapshot"},{"title":"readQuerySnapshot","description":"The `readQuerySnapshot` utility efficiently processes Firestore query snapshots, converting them into an array of document data objects, each paired with its corresponding document ID. It filters out non-existent documents, ensuring clean and reliable data arrays.","icon":"code","href":"/cloud/snapshots/readQuerySnapshot"}]},{"group":"Timestamps","pages":[{"title":"maxTimestamp","icon":"code","href":"/cloud/timestamps/maxTimestamp"},{"title":"hydrateAllTimestamps","description":"The `hydrateAllTimestamps` function is a powerful tool for converting all serialized Firestore timestamps within an object back into Firestore Timestamp objects. It is ideal for rehydrating timestamp data in complex objects, ensuring proper timestamp representation in Firestore.","icon":"code","href":"/cloud/timestamps/hydrateAllTimestamps"},{"title":"hydrateTimestamp","icon":"code","href":"/cloud/timestamps/hydrateTimestamp"},{"title":"minTimestamp","icon":"code","href":"/cloud/timestamps/minTimestamp"},{"title":"sortTimestamps","icon":"code","href":"/cloud/timestamps/sortTimestamps"},{"title":"timestampToDate","icon":"code","href":"/cloud/timestamps/timestampToDate"}]},{"group":"Metrics","pages":[{"title":"Metrics Overview","href":"/cloud/metrics/overview"},{"title":"incrementMetric","href":"/cloud/metrics/increment"},{"title":"updateMetric","href":"/cloud/metrics/update"},{"title":"Types Reference","href":"/cloud/metrics/types"},{"title":"Utilities","href":"/cloud/metrics/utilities"}]}]}]},"title":"maxTimestamp - Firebridge","buildId":"dpl_EnxDqhjaNc9a8MVa833TGULPd9uJ","deploymentId":"dpl_EnxDqhjaNc9a8MVa833TGULPd9uJ","dynamics":[],"chunks":[]}