# Timestamp Delay

**URL:** <https://forums.losant.com/t/timestamp-delay/2935>\
**Category:** Help\
**Tags:** edge\
**Created:** [May 12, 2020, 6:59am UTC](https://forums.losant.com/t/timestamp-delay/2935 "2020-05-12T06:59:43Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChrisGM](https://avatars.discourse-cdn.com/v4/letter/c/51bf81/32.png) [@ChrisGM](https://forums.losant.com/u/ChrisGM)\
**Post date:** [May 12, 2020, 6:59am UTC](https://forums.losant.com/t/timestamp-delay/2935/1 "2020-05-12T06:59:44Z")

</div>

Hi All,

I’m having an issue where my edge agent is running OK, however the data coming in has a delayed timestamp.

My workflow is very simple, with a 10 minute interval trigger driving the payloads.

I have connected to the agent (Pi) and made sure the timezone is set correctly, and enabled network time sync.

This appeared to for work for a very short time, but the delayed behaviour has started again.

You can see in the screenshot:  
The current time.  
The time of the payloads (interpreted time from ms conversion)  
The fact that they are coming in every 10 minutes regularly. Just always delayed.

 ![Capture timings](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/4/467070d54f98160e17a97bc9196aa389f7367c41.jpeg)

---

<div class="post-metadata">

**Author:** ![ChrisGM](https://avatars.discourse-cdn.com/v4/letter/c/51bf81/32.png) [@ChrisGM](https://forums.losant.com/u/ChrisGM)\
**Post date:** [May 12, 2020, 7:00am UTC](https://forums.losant.com/t/timestamp-delay/2935/2 "2020-05-12T07:00:20Z")

</div>

They are two different devices.  
Same behaviour.  
Slightly different delay.

---

<div class="post-metadata">

**Author:** ![anaptfox](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/anaptfox/32/873_2.png) [@anaptfox](https://forums.losant.com/u/anaptfox)\
**Post date:** [May 12, 2020, 1:55pm UTC](https://forums.losant.com/t/timestamp-delay/2935/5 "2020-05-12T13:55:34Z")

</div>

@ChrisGM,

Hello!

Within your Edge Workflows, what do you have at the “[Time](https://docs.losant.com/workflows/outputs/device-state/#time)” field?

---

<div class="post-metadata">

**Author:** ![ChrisGM](https://avatars.discourse-cdn.com/v4/letter/c/51bf81/32.png) [@ChrisGM](https://forums.losant.com/u/ChrisGM)\
**Post date:** [May 12, 2020, 2:17pm UTC](https://forums.losant.com/t/timestamp-delay/2935/6 "2020-05-12T14:17:05Z")

</div>

Do you mean on the debug for an incoming payload?

---

<div class="post-metadata">

**Author:** ![anaptfox](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/anaptfox/32/873_2.png) [@anaptfox](https://forums.losant.com/u/anaptfox)\
**Post date:** [May 12, 2020, 2:17pm UTC](https://forums.losant.com/t/timestamp-delay/2935/9 "2020-05-12T14:17:47Z")

</div>

Sorry, could have totally be more specific there!

I mean within the Device State Node thats reporting state.

---

<div class="post-metadata">

**Author:** ![ChrisGM](https://avatars.discourse-cdn.com/v4/letter/c/51bf81/32.png) [@ChrisGM](https://forums.losant.com/u/ChrisGM)\
**Post date:** [May 12, 2020, 2:18pm UTC](https://forums.losant.com/t/timestamp-delay/2935/10 "2020-05-12T14:18:46Z")

</div>

“Use the time of the current payload”

---

<div class="post-metadata">

**Author:** ![ChrisGM](https://avatars.discourse-cdn.com/v4/letter/c/51bf81/32.png) [@ChrisGM](https://forums.losant.com/u/ChrisGM)\
**Post date:** [May 12, 2020, 2:22pm UTC](https://forums.losant.com/t/timestamp-delay/2935/13 "2020-05-12T14:22:51Z")

</div>

I have just captured a debug message.  
The time is ‘in the past’.  
If you could send a link, i’ll send you an un-redacted screenshot of the payload debug.

---

<div class="post-metadata">

**Author:** ![anaptfox](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/anaptfox/32/873_2.png) [@anaptfox](https://forums.losant.com/u/anaptfox)\
**Post date:** [May 12, 2020, 2:23pm UTC](https://forums.losant.com/t/timestamp-delay/2935/15 "2020-05-12T14:23:32Z")

</div>

@ChrisGM,

Thank you! I’m not quite sure why you’re experiencing any delay. From the looks of your screenshots, it seems that both devices reported state every 10 mins. Could you give me a little more info on what you’re expecting?

---

<div class="post-metadata">

**Author:** ![ChrisGM](https://avatars.discourse-cdn.com/v4/letter/c/51bf81/32.png) [@ChrisGM](https://forums.losant.com/u/ChrisGM)\
**Post date:** [May 12, 2020, 2:25pm UTC](https://forums.losant.com/t/timestamp-delay/2935/16 "2020-05-12T14:25:33Z")

</div>

It’s not a physical delay. It’s just that the ‘time’ on the payload is 20 or 25 minutes in the past!  
Therefore even though I’m getting readings every 10 minutes, the database appears to not be recently updated, as the ‘latest reading’ is always 20 minutes old.

I think a screenshot might explain a little better!

---

<div class="post-metadata">

**Author:** ![ChrisGM](https://avatars.discourse-cdn.com/v4/letter/c/51bf81/32.png) [@ChrisGM](https://forums.losant.com/u/ChrisGM)\
**Post date:** [May 12, 2020, 2:27pm UTC](https://forums.losant.com/t/timestamp-delay/2935/17 "2020-05-12T14:27:13Z")

</div>

To add another clue:

If the workflow timer node triggers the workflow, the time on the payload is old.

if I use a ‘poll button’ to trigger the workflow, the time on the payload is correct.

---

<div class="post-metadata">

**Author:** ![anaptfox](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/anaptfox/32/873_2.png) [@anaptfox](https://forums.losant.com/u/anaptfox)\
**Post date:** [May 12, 2020, 2:31pm UTC](https://forums.losant.com/t/timestamp-delay/2935/18 "2020-05-12T14:31:18Z")

</div>

@ChrisGM,

Would you be able send me a screenshot to support the behavior your seeing?

I would love to see a screenshot that shows your current time and an old payload time using the Timer Node.

---

<div class="post-metadata">

**Author:** ![ChrisGM](https://avatars.discourse-cdn.com/v4/letter/c/51bf81/32.png) [@ChrisGM](https://forums.losant.com/u/ChrisGM)\
**Post date:** [May 12, 2020, 2:32pm UTC](https://forums.losant.com/t/timestamp-delay/2935/19 "2020-05-12T14:32:52Z")

</div>

Sure, can you please send me a PM?  
Will save me time editing!

---

<div class="post-metadata">

**Author:** ![ChrisGM](https://avatars.discourse-cdn.com/v4/letter/c/51bf81/32.png) [@ChrisGM](https://forums.losant.com/u/ChrisGM)\
**Post date:** [May 12, 2020, 3:05pm UTC](https://forums.losant.com/t/timestamp-delay/2935/20 "2020-05-12T15:05:23Z")

</div>

Here is the redacted screenshot

 ![Capture Timer Debug redacted](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/e/e2e5382a19661bcf7a351e5cd0d0eb541d76f635.jpeg)

---

<div class="post-metadata">

**Author:** ![anaptfox](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/anaptfox/32/873_2.png) [@anaptfox](https://forums.losant.com/u/anaptfox)\
**Post date:** [May 12, 2020, 10:09pm UTC](https://forums.losant.com/t/timestamp-delay/2935/21 "2020-05-12T22:09:14Z")

</div>

@ChrisGM,

That time is coming from the system time of your Edge Device. When you run the Linux command [date](http://man7.org/linux/man-pages/man1/date.1.html) on your edge device, do you see it 20 mins behind? Like so:

![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/d/dfd95194ff074bebd6e63af6ad7335df7f1f5b4d.png)

---

<div class="post-metadata">

**Author:** ![ChrisGM](https://avatars.discourse-cdn.com/v4/letter/c/51bf81/32.png) [@ChrisGM](https://forums.losant.com/u/ChrisGM)\
**Post date:** [May 13, 2020, 10:32am UTC](https://forums.losant.com/t/timestamp-delay/2935/23 "2020-05-13T10:32:06Z")

</div>

Time appears correctly (in sync with current real time)

 ![20200513_112641](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/e/e3fbcceb399dcfb55bf0901b926112de24d9905a.jpeg) ![20200513_112933](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/0/02de804ea89f66709f2b507d7ec0f845348b5a37.jpeg)

---

<div class="post-metadata">

**Author:** ![Brandon\_Cannaday](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/brandon_cannaday/32/14_2.png) [@Brandon\_Cannaday](https://forums.losant.com/u/Brandon_Cannaday)\
**Post date:** [May 14, 2020, 6:20am UTC](https://forums.losant.com/t/timestamp-delay/2935/25 "2020-05-14T06:20:16Z")

</div>

One more test is to verify the date inside the Edge Agent container itself is not delayed. You can do that by running the following command:

```nohighlight
docker exec <container-id> date

```

 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/4/4ebb74329d33a444ddfddc23087cef91192b7028.png)

---

<div class="post-metadata">

**Author:** ![ChrisGM](https://avatars.discourse-cdn.com/v4/letter/c/51bf81/32.png) [@ChrisGM](https://forums.losant.com/u/ChrisGM)\
**Post date:** [May 14, 2020, 10:55am UTC](https://forums.losant.com/t/timestamp-delay/2935/26 "2020-05-14T10:55:38Z")

</div>

The time appears to be correct.

Ran at 11:51am  
Time shown is 10:51 (UTC)

 ![20200514_115133](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/0/0726b57ce18c8db9a2d93e75eafbac914d4fe7a7.jpeg)

---

<div class="post-metadata">

**Author:** ![Brandon\_Cannaday](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/brandon_cannaday/32/14_2.png) [@Brandon\_Cannaday](https://forums.losant.com/u/Brandon_Cannaday)\
**Post date:** [May 14, 2020, 3:42pm UTC](https://forums.losant.com/t/timestamp-delay/2935/28 "2020-05-14T15:42:11Z")

</div>

We believe we have identified the issue. The underlying cause is a delay between when the Edge Agent initially launches and when NTP syncs the system time. Timers initialize their own time when the agent launches. Changes to system time do not affect them. This is because if the system time changes, the timer can end up being very confused.

There are a few fixes:

1. Restart the Docker container. This should re-initialize the container with the most up-to-date time.
2. When reporting Device state, use the [Use current time](https://docs.losant.com/workflows/outputs/device-state/#time) option, this will report state using the current system time.
3. Use a Date/Time Node at the beginning of the workflow to set the `time` payload path to the current system time.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/b/bbf54820bce500dfcb31aaeac2f4bccd732cf2dd.png)

---

<div class="post-metadata">

**Author:** ![ChrisGM](https://avatars.discourse-cdn.com/v4/letter/c/51bf81/32.png) [@ChrisGM](https://forums.losant.com/u/ChrisGM)\
**Post date:** [May 15, 2020, 7:41am UTC](https://forums.losant.com/t/timestamp-delay/2935/30 "2020-05-15T07:41:30Z")

</div>

@Brandon_Cannaday @anaptfox

Thank you both for your support.

Option 3 - Adding the Time/Date node is the ideal solution, tested as **working**.

I am going to do some archive tests to make sure ‘loss of comms’ events are covered, but if you don’t hear anything you can assume these also worked!

---

<div class="post-metadata">

**Author:** ![anaptfox](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/anaptfox/32/873_2.png) [@anaptfox](https://forums.losant.com/u/anaptfox)\
**Post date:** [May 15, 2020, 11:55am UTC](https://forums.losant.com/t/timestamp-delay/2935/32 "2020-05-15T11:55:13Z")

</div>

Awesome. This is the fun part of IoT. These challenges turn into cool projects and I’m exited to see yours come to life!
