# How to automatically set the server date/time when adding data?

**URL:** <https://discuss.elastic.co/t/how-to-automatically-set-the-server-date-time-when-adding-data/296708>\
**Category:** Elasticsearch\
**Created:** [February 9, 2022, 10:28am UTC](https://discuss.elastic.co/t/how-to-automatically-set-the-server-date-time-when-adding-data/296708 "2022-02-09T10:28:02Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 9, 2022, 10:49am UTC](https://discuss.elastic.co/t/how-to-automatically-set-the-server-date-time-when-adding-data/296708/2 "2022-02-09T10:49:10Z")

</div>

Bonjour Vincent! 😉

I believe you can do something like this using an ingest pipeline with a `Set` processor.

And you can make the pipeline a default pipeline for your index. (See [Ingest pipelines | Elasticsearch Guide [7.17] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ingest.html#set-default-pipeline))

Full example (from this example [Ingest pipelines | Elasticsearch Guide [7.17] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ingest.html#access-ingest-metadata)):

```auto
PUT _ingest/pipeline/set-timestamp
{
  "description": "sets the timestamp",
  "processors": [
    {
      "set": {
        "field": "timestamp",
        "value": "{{{_ingest.timestamp}}}"
      }
    }
  ]
}
DELETE test
PUT test
{
  "settings": {
    "index.default_pipeline": "set-timestamp"
  },
  "mappings": {
    "properties": {
      "timestamp": {
        "type": "date"
      }
    }
  }
}
PUT test/_doc/1
{
  "foo": "bar"
}
GET test/_doc/1

```

Gives:

```auto
{
  "_index" : "test",
  "_type" : "_doc",
  "_id" : "1",
  "_version" : 1,
  "_seq_no" : 0,
  "_primary_term" : 1,
  "found" : true,
  "_source" : {
    "foo" : "bar",
    "timestamp" : "2022-02-09T10:47:34.880561Z"
  }
}

```

---

_[View the full topic](https://discuss.elastic.co/t/how-to-automatically-set-the-server-date-time-when-adding-data/296708)._
