# Timestamp in pre-execution script for HTPP monitors

**URL:** <https://community.dynatrace.com/t/timestamp-in-pre-execution-script-for-htpp-monitors/20711>\
**Category:** Synthetic Monitoring\
**Tags:** http-monitor\
**Created:** [November 3, 2020, 12:15pm UTC](https://community.dynatrace.com/t/timestamp-in-pre-execution-script-for-htpp-monitors/20711 "2020-11-03T12:15:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![iromaniuk](https://avatars.discourse-cdn.com/v4/letter/i/6a8cbe/32.png) [@iromaniuk](https://community.dynatrace.com/u/iromaniuk)\
**Post date:** [November 3, 2020, 12:15pm UTC](https://community.dynatrace.com/t/timestamp-in-pre-execution-script-for-htpp-monitors/20711/1 "2020-11-03T12:15:47Z")

</div>

I am posting data points in pre-execution script and dont know how to create timestamp, trying **Date.parse(api.date()**) below, What’s the correct way to do this ?

```auto
requestBody={
"type": "LB",
"series": [
{
"timeseriesId": "custom:alteon.CurrSessions",
"dimensions": {
"CUSTOM_DEVICE": "Load Balancers"
},
"dataPoints": [
[
Date.parse(api.date()),
api.randomNextInt()
]
]
}
]
};
request.setBody(requestBody);

```

---

<div class="post-metadata">

**Author:** ![hannahmac](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/hannahmac/32/41823_2.png) [@hannahmac](https://community.dynatrace.com/u/hannahmac)\
**Post date:** [November 3, 2020, 12:42pm UTC](https://community.dynatrace.com/t/timestamp-in-pre-execution-script-for-htpp-monitors/20711/2 "2020-11-03T12:42:18Z")

</div>

I would use a variable and get the value before you start to create the requestBody. Something like this:

var timestampNow = api.date();

and then use the variable later. Or if you need it to be in a specific format you can use api.dateToFormat. You can find a couple of examples [here](https://www.dynatrace.com/support/help/shortlink/http-monitor-pre-post-script#date-formatting)
