# Get Timestamp of value in provision

**URL:** <https://forum.genieacs.com/t/get-timestamp-of-value-in-provision/941>\
**Category:** Uncategorized\
**Created:** [August 10, 2020, 9:51am UTC](https://forum.genieacs.com/t/get-timestamp-of-value-in-provision/941 "2020-08-10T09:51:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![simon](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@simon](https://forum.genieacs.com/u/simon)\
**Post date:** [August 10, 2020, 9:51am UTC](https://forum.genieacs.com/t/get-timestamp-of-value-in-provision/941/1 "2020-08-10T09:51:13Z")

</div>

Hi,

I understand that I can refresh values based on the timestamp of that value from the Database.  
E.g.

```auto
let manufacturer = declare("InternetGatewayDevice.DeviceInfo.Manufacturer", { value: 1 }).value[0];

```

does not re-read the value from the device if it already exists on the database. However is there any way I can get the timestamp within my provision at the time the value has been gathered from the device / written to the database (i.e. the one which I see in the UI when I mouseover the entry)?

---

<div class="post-metadata">

**Author:** ![lavira](https://avatars.discourse-cdn.com/v4/letter/l/87869e/32.png) [@lavira](https://forum.genieacs.com/u/lavira)\
**Post date:** [August 10, 2020, 4:21pm UTC](https://forum.genieacs.com/t/get-timestamp-of-value-in-provision/941/2 "2020-08-10T16:21:34Z")

</div>

you are giving 1 as the timestamp for the value you want to receive and this means that genieacs will refresh the value from the device only if it is missing from the database. To read the current value from the device you must provide the current timestamp:

```auto
const now = Date.now();
let manufacturer = declare("InternetGatewayDevice.DeviceInfo.Manufacturer", { value: now }).value[0];

```

---

<div class="post-metadata">

**Author:** ![simon](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@simon](https://forum.genieacs.com/u/simon)\
**Post date:** [August 10, 2020, 4:45pm UTC](https://forum.genieacs.com/t/get-timestamp-of-value-in-provision/941/3 "2020-08-10T16:45:41Z")

</div>

Hi lavira,

exactly. However my questions here is _not_ how I get the most current value from the device but how to find out what the timestamp of that value is from the time it has been written to the database. Or let’s say the “age” of that value seen from the GenieACS standpoint.

E.g. sometimes I want to grab the most current values `Date.now()` (obviously the timestamp / age of that is “Date.now()”). Sometimes I like to grab the value every 24h `Date.now(24 * 60 * 60 * 1000)` or any other longer interval. However I don’t know the age of that value when running the provision more often than my date-function.

Hope that makes it a bit more clear.

---

<div class="post-metadata">

**Author:** ![lavira](https://avatars.discourse-cdn.com/v4/letter/l/87869e/32.png) [@lavira](https://forum.genieacs.com/u/lavira)\
**Post date:** [August 10, 2020, 5:23pm UTC](https://forum.genieacs.com/t/get-timestamp-of-value-in-provision/941/4 "2020-08-10T17:23:22Z")

</div>

Oh, I see … I don’t think you can access this info from inside the provisioning scripts as these run inside a sandbox. If you try to read the data from outside via the API calls, you receive also the database timestamp and if the value is writable …etc. But you don’t really need to find out the timestamp if all you want it to grab data every X hours … you can achieve that by:

- adding a cron expression to the preset that is running the provision script
- manipulate the timestamp to reflect the interval that you want, something like:

```auto
let now=Date.now();

// every 24h
now=now-now%(24*60*60*1000);

// every 3 hours
now=now-now%(3*60*60*1000);

```

---

<div class="post-metadata">

**Author:** ![JonasGhost](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/jonasghost/32/286_2.png) [@JonasGhost](https://forum.genieacs.com/u/JonasGhost)\
**Post date:** [March 14, 2022, 9:13am UTC](https://forum.genieacs.com/t/get-timestamp-of-value-in-provision/941/5 "2022-03-14T09:13:27Z")

</div>

I currently have the same problem.  
I want to know, if a values was read in the current session or not without triggering a reading of that value.  
I have tried the way over the api from external, did not work as I intended.
