Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set server value now as timestamp

I'm trying to write the now timestamp using the rest api of firestore. The sending application doesn't keep the time so its up to the server to store the value.

{
    "fields": {
        "Type": {
            "stringValue": "temperature"
            },
            "Timestamp": {
                "timestampValue": "2019-02-18T23:00:00Z"
            },
            "Value": {
                "integerValue": "17"
            }
    }
}

The values get stored properly but I want to be able to change the static 2019-02-18T23:00:00Z to the now value.

How can this be done?

like image 521
Tarscher Avatar asked Aug 10 '26 06:08

Tarscher


1 Answers

To write the server-side timestamp in a field, you need to use a FieldTransform for that. See Firestore REST API add Timestamp and https://cloud.google.com/firestore/docs/reference/rest/v1/Write

like image 168
Frank van Puffelen Avatar answered Aug 14 '26 14:08

Frank van Puffelen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!