4.6.0 (latest) 4.5.0 4.4.0 4.3.0 4.2.0 4.1.0 4.0.0 3.13.0 3.12.0 3.11.0 3.10.0 3.9.0 3.8.0 3.7.0 3.6.0 3.5.1 3.4.0 3.3.0 3.2.0 3.1.0 3.0.0 2.5.0 2.4.0 2.3.1

    public struct Timestamp : IEquatable<Timestamp>, IComparable, IComparable<Timestamp>

Reference documentation and code samples for the Firestore API struct Timestamp.

A nanosecond-precision immutable timestamp. When this is stored as part of a document in Firestore,
it is truncated to the microsecond, towards the start of time.

## Implements

[IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[Timestamp](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.Timestamp), [IComparable](https://learn.microsoft.com/dotnet/api/system.icomparable), [IComparable](https://learn.microsoft.com/dotnet/api/system.icomparable-1)[Timestamp](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.Timestamp)

## Inherited Members

[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype)

## Namespace

[Google.Cloud.Firestore](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore)

## Assembly

Google.Cloud.Firestore.dll

## Methods

### CompareTo(Timestamp)

    public int CompareTo(Timestamp other)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `other` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.Timestamp` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.int32` |   |

### CompareTo(object)

    public int CompareTo(object obj)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `obj` | `https://learn.microsoft.com/dotnet/api/system.object` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.int32` |   |

### FromDateTime(DateTime)

    public static Timestamp FromDateTime(DateTime dateTime)

Converts a [DateTime](https://learn.microsoft.com/dotnet/api/system.datetime) to a [Timestamp](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.Timestamp).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `dateTime` | `https://learn.microsoft.com/dotnet/api/system.datetime` The value to convert; its kind must be [Utc](https://learn.microsoft.com/dotnet/api/system.datetimekind#system-datetimekind-utc). |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.Timestamp` | A [Timestamp](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.Timestamp) representation of `dateTime`. |

### FromDateTimeOffset(DateTimeOffset)

    public static Timestamp FromDateTimeOffset(DateTimeOffset dateTimeOffset)

Converts the given [DateTimeOffset](https://learn.microsoft.com/dotnet/api/system.datetimeoffset) to a [Timestamp](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.Timestamp)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `dateTimeOffset` | `https://learn.microsoft.com/dotnet/api/system.datetimeoffset` The date and time (with UTC offset) to convert to a timestamp. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.Timestamp` | The converted timestamp. |

**Remarks** The offset is taken into consideration when converting the value (so the same instant in time
is represented) but is not a separate part of the resulting value. In other words, there is no
roundtrip operation to retrieve the original `DateTimeOffset`.

### FromProto(Timestamp)

    public static Timestamp FromProto(Timestamp proto)

Creates an instance from a Protobuf [Timestamp](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.WellKnownTypes.Timestamp.html) representation.
Later modifications to the Protobuf representation will not affect the returned oject.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `proto` | `https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.WellKnownTypes.Timestamp.html` A Protobuf timestamp representation. Must not be null. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.Timestamp` | An immutable timestamp. |

### GetCurrentTimestamp()

    public static Timestamp GetCurrentTimestamp()

Returns the current timestamp according to the system clock. The system time zone
is irrelevant, as a timestamp represents an instant in time.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.Timestamp` | The current timestamp according to the system clock. |

### GetHashCode()

    public override int GetHashCode()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.int32` |   |

**Overrides** [ValueType.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.valuetype.gethashcode)

### ToDateTime()

    public DateTime ToDateTime()

Converts this timestamp to a [DateTime](https://learn.microsoft.com/dotnet/api/system.datetime) with a kind of
[Utc](https://learn.microsoft.com/dotnet/api/system.datetimekind#system-datetimekind-utc). This can lose information as DateTime has a precision of
a tick (100 nanoseconds). If the timestamp is not a precise number of ticks, it will be
truncated towards the start of time.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.datetime` | A [DateTime](https://learn.microsoft.com/dotnet/api/system.datetime) representation of this timestamp. |

### ToDateTimeOffset()

    public DateTimeOffset ToDateTimeOffset()

Converts this timestamp into a [DateTimeOffset](https://learn.microsoft.com/dotnet/api/system.datetimeoffset).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.datetimeoffset` | This timestamp as a `DateTimeOffset`. |

**Remarks** The resulting `DateTimeOffset` will always have an `Offset` of zero.
If the timestamp is not a precise number of ticks, it will be truncated towards the start
of time.
[DateTimeOffset](https://learn.microsoft.com/dotnet/api/system.datetimeoffset) value precisely on a second.

### ToProto()

    public Timestamp ToProto()

Creates a Protobuf [Timestamp](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.WellKnownTypes.Timestamp.html) representation of this
timestamp. Modifications to the returned message will not be reflected in this object.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.WellKnownTypes.Timestamp.html` | A Protobuf timestamp representation. |

### ToString()

    public override string ToString()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` |   |

**Overrides** [ValueType.ToString()](https://learn.microsoft.com/dotnet/api/system.valuetype.tostring)

## Operators

### operator ==(Timestamp, Timestamp)

    public static bool operator ==(Timestamp lhs, Timestamp rhs)

Operator overload to compare two Blob values for equality.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `lhs` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.Timestamp` Left value to compare |
| `rhs` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.Timestamp` Right value to compare |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.boolean` | true if `lhs` is equal to `rhs`; otherwise false. |

### operator \>(Timestamp, Timestamp)

    public static bool operator >(Timestamp lhs, Timestamp rhs)

Compares two timestamps.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `lhs` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.Timestamp` The left timestamp to compare. |
| `rhs` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.Timestamp` The right timestamp to compare. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.boolean` | true is `lhs` is strictly later than `rhs`; otherwise false. |

### operator \>=(Timestamp, Timestamp)

    public static bool operator >=(Timestamp lhs, Timestamp rhs)

Compares two timestamps.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `lhs` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.Timestamp` The left timestamp to compare. |
| `rhs` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.Timestamp` The right timestamp to compare. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.boolean` | true is `lhs` is later than or equal to `rhs`; otherwise false. |

### operator !=(Timestamp, Timestamp)

    public static bool operator !=(Timestamp lhs, Timestamp rhs)

Operator overload to compare two Blob values for inequality.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `lhs` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.Timestamp` Left value to compare |
| `rhs` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.Timestamp` Right value to compare |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.boolean` | false if `lhs` is equal to `rhs`; otherwise true. |

### operator \<(Timestamp, Timestamp)

    public static bool operator <(Timestamp lhs, Timestamp rhs)

Compares two timestamps.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `lhs` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.Timestamp` The left timestamp to compare. |
| `rhs` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.Timestamp` The right timestamp to compare. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.boolean` | true is `lhs` is strictly earlier than `rhs`; otherwise false. |

### operator \<=(Timestamp, Timestamp)

    public static bool operator <=(Timestamp lhs, Timestamp rhs)

Compares two timestamps.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `lhs` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.Timestamp` The left timestamp to compare. |
| `rhs` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.Timestamp` The right timestamp to compare. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.boolean` | true is `lhs` is earlier than or equal to `rhs`; otherwise false. |