# Not able to populate @timestamp value to a table in html file

**URL:** <https://discuss.elastic.co/t/not-able-to-populate-timestamp-value-to-a-table-in-html-file/39070>\
**Category:** Elasticsearch\
**Created:** [January 13, 2016, 7:45am UTC](https://discuss.elastic.co/t/not-able-to-populate-timestamp-value-to-a-table-in-html-file/39070 "2016-01-13T07:45:55Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![vivc](https://avatars.discourse-cdn.com/v4/letter/v/ce7236/32.png) [@vivc](https://discuss.elastic.co/u/vivc)\
**Post date:** [January 13, 2016, 7:45am UTC](https://discuss.elastic.co/t/not-able-to-populate-timestamp-value-to-a-table-in-html-file/39070/1 "2016-01-13T07:45:55Z")

</div>

I'm trying to populate @timestamp value to a table using the following code.

// $(row).html(item.\_source.message);  
$(row).html(item.\_source.\_timestamp);  
this is not working  
but other fields apart from @timestamp we are able to populate to the table  
Do you know how to populate @timestamp value to table.

Please help me in how we can do this.

We are quering the @timestamp value using moustache file from elastic search.

---

<div class="post-metadata">

**Author:** ![shaunak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaunak/32/6643_2.png) [@shaunak](https://discuss.elastic.co/u/shaunak)\
**Post date:** [January 13, 2016, 12:27pm UTC](https://discuss.elastic.co/t/not-able-to-populate-timestamp-value-to-a-table-in-html-file/39070/2 "2016-01-13T12:27:57Z")

</div>

Have you tried `item.source.@timestamp` or `item.source['@timestamp']`?

---

<div class="post-metadata">

**Author:** ![vivc](https://avatars.discourse-cdn.com/v4/letter/v/ce7236/32.png) [@vivc](https://discuss.elastic.co/u/vivc)\
**Post date:** [January 13, 2016, 4:17pm UTC](https://discuss.elastic.co/t/not-able-to-populate-timestamp-value-to-a-table-in-html-file/39070/3 "2016-01-13T16:17:01Z")

</div>

> [@vivc](#):
>
> // $(row).html(item.\_source.message);

Yes, we have tried both that is giving syntax error.  
item.\_source.@timestamp or item.\_source['@timestamp']?

But // $(row).html(item.\_source.message); is working .

---

<div class="post-metadata">

**Author:** ![shaunak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaunak/32/6643_2.png) [@shaunak](https://discuss.elastic.co/u/shaunak)\
**Post date:** [January 13, 2016, 4:57pm UTC](https://discuss.elastic.co/t/not-able-to-populate-timestamp-value-to-a-table-in-html-file/39070/4 "2016-01-13T16:57:54Z")

</div>

Can you share the syntax error?

Also, just for debugging purposes, can you output the entirety of `item._source` and paste it here?

---

<div class="post-metadata">

**Author:** ![vivc](https://avatars.discourse-cdn.com/v4/letter/v/ce7236/32.png) [@vivc](https://discuss.elastic.co/u/vivc)\
**Post date:** [January 13, 2016, 5:31pm UTC](https://discuss.elastic.co/t/not-able-to-populate-timestamp-value-to-a-table-in-html-file/39070/5 "2016-01-13T17:31:11Z")

</div>

Please find the syntax error

Uncaught SyntaxError: Unexpected token ILLEGAL

Code:  
resp.hits.hits.forEach( function(item) {  
var row = "#srchres table tr:nth-child("+i+") td:nth-child(2)";  
$(row).html(item.\_source.@timestamp);  
// $(row).html(item.\_source.message);  
// $(row).html( item.\_source['@timestamp']);  
i++;  
});

Please find the item.\_source

{  
"\_index": "logstash-2016.01.05",  
"\_type": "logs",  
"\_id": "AVIQkVhZdgDuKuS\_rjvC",  
"\_score": 1.4354146,  
"\_source": {  
"@timestamp": "2016-01-05T06:55:04.189Z",  
"message": "2015/11/10 20:48:28 [ERRTEST] /SW2/spanky/i2c-3/FT3: Read Reg 21"  
}

---

<div class="post-metadata">

**Author:** ![shaunak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaunak/32/6643_2.png) [@shaunak](https://discuss.elastic.co/u/shaunak)\
**Post date:** [January 13, 2016, 5:45pm UTC](https://discuss.elastic.co/t/not-able-to-populate-timestamp-value-to-a-table-in-html-file/39070/6 "2016-01-13T17:45:08Z")

</div>

Inside the `forEach` can you do a `console.log(item._source)` and paste it's output here, please?

---

<div class="post-metadata">

**Author:** ![vivc](https://avatars.discourse-cdn.com/v4/letter/v/ce7236/32.png) [@vivc](https://discuss.elastic.co/u/vivc)\
**Post date:** [January 14, 2016, 5:57am UTC](https://discuss.elastic.co/t/not-able-to-populate-timestamp-value-to-a-table-in-html-file/39070/7 "2016-01-14T05:57:28Z")

</div>

Please find the output

Object {@timestamp: "2016-01-05T06:55:04.189Z", message: "2015/11/10 20:48:28 [ERRTEST] /SW2/spanky/i2c-3/FT3: Read Reg 21"}

---

<div class="post-metadata">

**Author:** ![shaunak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaunak/32/6643_2.png) [@shaunak](https://discuss.elastic.co/u/shaunak)\
**Post date:** [January 14, 2016, 8:14am UTC](https://discuss.elastic.co/t/not-able-to-populate-timestamp-value-to-a-table-in-html-file/39070/8 "2016-01-14T08:14:15Z")

</div>

Okay, so that clearly indicates that `@timestamp` is part of the object. I think this is a jQuery escaping issue. I'm not a jQuery expert but I'd suggest trying to escape the `@` character. Maybe try `item._source['\\@timestamp']`, according to [https://api.jquery.com/category/selectors/](https://api.jquery.com/category/selectors/)?

---

<div class="post-metadata">

**Author:** ![vivc](https://avatars.discourse-cdn.com/v4/letter/v/ce7236/32.png) [@vivc](https://discuss.elastic.co/u/vivc)\
**Post date:** [January 14, 2016, 10:13am UTC](https://discuss.elastic.co/t/not-able-to-populate-timestamp-value-to-a-table-in-html-file/39070/9 "2016-01-14T10:13:21Z")

</div>

Thanks. I've tried thus but getting syntax error. Even i'm learning Jquery.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:24pm UTC](https://discuss.elastic.co/t/not-able-to-populate-timestamp-value-to-a-table-in-html-file/39070/10 "2017-07-05T23:24:35Z")

</div>


