A representation of the Spanner TIMESTAMP type: An instant in time.
A Timestamp represents an absolute point in time (i.e., is independent of any time zone), with at least nanosecond precision, and with a range of 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z, inclusive.
The MakeTimestamp(src) factory function(s) should be used to construct Timestamp values from standard representations of absolute time.
A Timestamp can be converted back to a standard representation using ts.get<T>().
Regular value type, supporting copy, assign, move.
Parameter
Name
Description
Timestamp &&
Timestamp(Timestamp const &)
Regular value type, supporting copy, assign, move.
Parameter
Name
Description
Timestamp const &
Timestamp()
Default construction yields 1970-01-01T00:00:00Z.
Operators
operator=(Timestamp &&)
Regular value type, supporting copy, assign, move.
Parameter
Name
Description
Timestamp &&
Returns
Type
Description
Timestamp &
operator=(Timestamp const &)
Regular value type, supporting copy, assign, move.
Parameter
Name
Description
Timestamp const &
Returns
Type
Description
Timestamp &
Functions
get() const
Convert the Timestamp to the user-specified template type.
Fails if *this cannot be represented as a T.
Supported destination types are:
absl::Time - Since absl::Time can represent all possible Timestamp values, get<absl::Time>() never returns an error.
google::protobuf::Timestamp - Never returns an error, but any sub-nanosecond precision will be lost.
google::cloud::spanner::sys_time<Duration> - Duration::rep may not be wider than std::int64_t, and Duration::period may be no more precise than std::nano.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-22 UTC."],[[["\u003cp\u003eThis document outlines the \u003ccode\u003eTimestamp\u003c/code\u003e class in Google Cloud Spanner, representing an absolute point in time with at least nanosecond precision, independent of time zones, and it has a range from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eTimestamp\u003c/code\u003e values can be created using the \u003ccode\u003eMakeTimestamp(src)\u003c/code\u003e factory function, enabling conversion from standard time representations.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eget<T>()\u003c/code\u003e method allows conversion of a \u003ccode\u003eTimestamp\u003c/code\u003e back into standard time formats, such as \u003ccode\u003eabsl::Time\u003c/code\u003e, \u003ccode\u003egoogle::protobuf::Timestamp\u003c/code\u003e, or \u003ccode\u003egoogle::cloud::spanner::sys_time<Duration>\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe document also lists various versions of the \u003ccode\u003eTimestamp\u003c/code\u003e class, starting from version 2.11.0 and going all the way up to the latest release candidate 2.37.0-rc.\u003c/p\u003e\n"],["\u003cp\u003eThe Timestamp class is a regular value type, and support copy, assign, and move operations, having the default value of 1970-01-01T00:00:00Z.\u003c/p\u003e\n"]]],[],null,["# Class Timestamp (2.24.0)\n\nVersion 2.24.0keyboard_arrow_down\n\n- [2.42.0-rc (latest)](/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Timestamp)\n- [2.41.0](/cpp/docs/reference/spanner/2.41.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp)\n- [2.40.0](/cpp/docs/reference/spanner/2.40.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp)\n- [2.39.0](/cpp/docs/reference/spanner/2.39.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp)\n- [2.38.0](/cpp/docs/reference/spanner/2.38.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp)\n- [2.37.0](/cpp/docs/reference/spanner/2.37.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp)\n- [2.36.0](/cpp/docs/reference/spanner/2.36.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp)\n- [2.35.0](/cpp/docs/reference/spanner/2.35.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp)\n- [2.34.0](/cpp/docs/reference/spanner/2.34.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp)\n- [2.33.0](/cpp/docs/reference/spanner/2.33.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp)\n- [2.32.0](/cpp/docs/reference/spanner/2.32.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp)\n- [2.31.0](/cpp/docs/reference/spanner/2.31.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp)\n- [2.30.0](/cpp/docs/reference/spanner/2.30.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp)\n- [2.29.0](/cpp/docs/reference/spanner/2.29.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp)\n- [2.28.0](/cpp/docs/reference/spanner/2.28.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp)\n- [2.27.0](/cpp/docs/reference/spanner/2.27.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp)\n- [2.26.0](/cpp/docs/reference/spanner/2.26.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp)\n- [2.25.1](/cpp/docs/reference/spanner/2.25.1/classgoogle_1_1cloud_1_1spanner_1_1Timestamp)\n- [2.24.0](/cpp/docs/reference/spanner/2.24.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp)\n- [2.23.0](/cpp/docs/reference/spanner/2.23.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp)\n- [2.22.1](/cpp/docs/reference/spanner/2.22.1/classgoogle_1_1cloud_1_1spanner_1_1Timestamp)\n- [2.21.0](/cpp/docs/reference/spanner/2.21.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp)\n- [2.20.0](/cpp/docs/reference/spanner/2.20.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp)\n- [2.19.0](/cpp/docs/reference/spanner/2.19.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp)\n- [2.18.0](/cpp/docs/reference/spanner/2.18.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp)\n- [2.17.0](/cpp/docs/reference/spanner/2.17.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp)\n- [2.16.0](/cpp/docs/reference/spanner/2.16.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp)\n- [2.15.1](/cpp/docs/reference/spanner/2.15.1/classgoogle_1_1cloud_1_1spanner_1_1Timestamp)\n- [2.14.0](/cpp/docs/reference/spanner/2.14.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp)\n- [2.13.0](/cpp/docs/reference/spanner/2.13.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp)\n- [2.12.0](/cpp/docs/reference/spanner/2.12.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp)\n- [2.11.0](/cpp/docs/reference/spanner/2.11.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp) \nA representation of the Spanner TIMESTAMP type: An instant in time. \nA [`Timestamp`](/cpp/docs/reference/spanner/2.24.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp) represents an absolute point in time (i.e., is independent of any time zone), with at least nanosecond precision, and with a range of 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z, inclusive.\n\nThe [`MakeTimestamp(src)`](about:invalid#zCSafez) factory function(s) should be used to construct [`Timestamp`](/cpp/docs/reference/spanner/2.24.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp) values from standard representations of absolute time.\n\nA [`Timestamp`](/cpp/docs/reference/spanner/2.24.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp) can be converted back to a standard representation using `ts.get\u003cT\u003e()`.\n\n###### See Also\n\n\u003chttps://cloud.google.com/spanner/docs/data-types#timestamp_type\u003e\n\nConstructors\n------------\n\n### Timestamp(Timestamp \\&\\&)\n\nRegular value type, supporting copy, assign, move.\n\n### Timestamp(Timestamp const \\&)\n\nRegular value type, supporting copy, assign, move.\n\n### Timestamp()\n\nDefault construction yields 1970-01-01T00:00:00Z.\n\nOperators\n---------\n\n### operator=(Timestamp \\&\\&)\n\nRegular value type, supporting copy, assign, move.\n\n### operator=(Timestamp const \\&)\n\nRegular value type, supporting copy, assign, move.\n\nFunctions\n---------\n\n### get() const\n\nConvert the [`Timestamp`](/cpp/docs/reference/spanner/2.24.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp) to the user-specified template type. \nFails if `*this` cannot be represented as a `T`.\n\nSupported destination types are:\n\n- `absl::Time` - Since `absl::Time` can represent all possible [`Timestamp`](/cpp/docs/reference/spanner/2.24.0/classgoogle_1_1cloud_1_1spanner_1_1Timestamp) values, `get\u003cabsl::Time\u003e()` never returns an error.\n- `google::protobuf::Timestamp` - Never returns an error, but any sub-nanosecond precision will be lost.\n- [`google::cloud::spanner::sys_time`](/cpp/docs/reference/spanner/2.24.0/namespacegoogle_1_1cloud_1_1spanner)`\u003cDuration\u003e` - `Duration::rep` may not be wider than `std::int64_t`, and `Duration::period` may be no more precise than `std::nano`.\n\n###### Example\n\n sys_time\u003cstd::chrono::nanoseconds\u003e tp = ...;\n Timestamp ts = MakeTimestamp(tp).value();\n assert(tp == ts.get\u003csys_time\u003cstd::chrono::nanoseconds\u003e\u003e().value());"]]