# Weird behaviour in CSV write

**URL:** <https://forums.losant.com/t/weird-behaviour-in-csv-write/4764>\
**Category:** Help\
**Tags:** csv\
**Created:** [October 8, 2022, 9:59pm UTC](https://forums.losant.com/t/weird-behaviour-in-csv-write/4764 "2022-10-08T21:59:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paolo\_Proxy](https://avatars.discourse-cdn.com/v4/letter/p/b5ac83/32.png) [@Paolo\_Proxy](https://forums.losant.com/u/Paolo_Proxy)\
**Post date:** [October 8, 2022, 9:59pm UTC](https://forums.losant.com/t/weird-behaviour-in-csv-write/4764/1 "2022-10-08T21:59:42Z")

</div>

Hi there,  
this is strange, why the CSV function block converts the time string into a linux epoch format?

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

I don’t see any option in the CSV block that can enable/disable this behavior.  
I just want simply to keep the date time as a string.  
Cheers.

---

<div class="post-metadata">

**Author:** ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)\
**Post date:** [October 9, 2022, 2:59pm UTC](https://forums.losant.com/t/weird-behaviour-in-csv-write/4764/2 "2022-10-09T14:59:33Z")

</div>

The data returned by the [Data: Time Series Node](https://docs.losant.com/workflows/data/time-series/) has the `time` value in [EJSON](https://www.mongodb.com/docs/manual/reference/mongodb-extended-json/) $date format - which, when encoded into a CSV string as you’ve discovered, falls back to an Epoch millisecond timestamp.

An easy working would be to drop a [Function Node](https://docs.losant.com/workflows/logic/function/) between your Data: Time Series Node and the [CSV: Encode Node](https://docs.losant.com/workflows/logic/csv-encode/) with the following content:

```auto
payload.working.data = payload.working.data.map((pt) => {
    return {
        ...pt,
        time: new Date(pt.time).toString()
    }
})

```

Depending on what string format you want that `time` value to be in, you could swap that `toString()` out for one of the other built-in [date string methods](https://www.w3schools.com/jsref/jsref_obj_date.asp), or construct your own using the other methods exposed on the object.
