voluptasmollitia
Version:
Monorepo for the Firebase JavaScript SDK
46 lines (31 loc) • 3.12 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@firebase/firestore](./firestore.md) > [/](./firestore_.md) > [Timestamp](./firestore_.timestamp.md)
## Timestamp class
A `Timestamp` represents a point in time independent of any time zone or calendar, represented as seconds and fractions of seconds at nanosecond resolution in UTC Epoch time.
It is encoded using the Proleptic Gregorian Calendar which extends the Gregorian calendar backwards to year one. It is encoded assuming all minutes are 60 seconds long, i.e. leap seconds are "smeared" so that no leap second table is needed for interpretation. Range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.
For examples and further specifications, refer to the [Timestamp definition](https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto)<!-- -->.
<b>Signature:</b>
```typescript
export declare class Timestamp
```
## Constructors
| Constructor | Modifiers | Description |
| --- | --- | --- |
| [(constructor)(seconds, nanoseconds)](./firestore_.timestamp._constructor_.md) | | Creates a new timestamp. |
## Properties
| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [nanoseconds](./firestore_.timestamp.nanoseconds.md) | | number | The fractions of a second at nanosecond resolution.\* |
| [seconds](./firestore_.timestamp.seconds.md) | | number | The number of seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. |
## Methods
| Method | Modifiers | Description |
| --- | --- | --- |
| [fromDate(date)](./firestore_.timestamp.fromdate.md) | <code>static</code> | Creates a new timestamp from the given date. |
| [fromMillis(milliseconds)](./firestore_.timestamp.frommillis.md) | <code>static</code> | Creates a new timestamp from the given number of milliseconds. |
| [isEqual(other)](./firestore_.timestamp.isequal.md) | | Returns true if this <code>Timestamp</code> is equal to the provided one. |
| [now()](./firestore_.timestamp.now.md) | <code>static</code> | Creates a new timestamp with the current date, with millisecond precision. |
| [toDate()](./firestore_.timestamp.todate.md) | | Converts a <code>Timestamp</code> to a JavaScript <code>Date</code> object. This conversion causes a loss of precision since <code>Date</code> objects only support millisecond precision. |
| [toJSON()](./firestore_.timestamp.tojson.md) | | Returns a JSON-serializable representation of this Timestamp. |
| [toMillis()](./firestore_.timestamp.tomillis.md) | | Converts a <code>Timestamp</code> to a numeric timestamp (in milliseconds since epoch). This operation causes a loss of precision. |
| [toString()](./firestore_.timestamp.tostring.md) | | Returns a textual representation of this Timestamp. |
| [valueOf()](./firestore_.timestamp.valueof.md) | | Converts this object to a primitive string, which allows Timestamp objects to be compared using the <code>></code>, <code><=</code>, <code>>=</code> and <code>></code> operators. |