<p>The problem is not with the timestamp, it's with your method of converting the timestamp to local time.</p>

<p>As <a href="https://stackoverflow.com/questions/4631928/convert-utc-epoch-to-local-date-with-javascript">this SO question</a> describes, convert it this way:</p>

<pre><code>var dt = new Date(0);
dt.setUTCSeconds(1454846632);
console.log(dt.toString());
</code></pre>

<p>Which prints <code>Sun Feb 07 2016 07:03:52 GMT-0500 (EST)</code>. </p>

CC BY-SA 3.0
2016-02-08T17:53:31.947Z
2016-02-08T17:53:31.947Z
2017-05-23T12:34:59.703Z
morsecoder
<p>I'm fetching my active credits in BFX and trying to discover when I'll have my funding back. This is a response example:</p>

<p><code>/v1/credits</code></p>

<pre><code>[{
    amount: "294.4316181",
    currency: "USD",
    id: 15778083,
    period: 2,
    rate: "16.816",
    status: "ACTIVE",
    timestamp: "1454846632.0"
}, ...
]
</code></pre>

<p>But <code>new Date(1454846632.0)</code> returns a very old date, what makes me think this timestamp isn't there to be converted into a real date at all.</p>

<p>I am doing something wrong? How can I discover the remaining time of a credit I provided?</p>

CC BY-SA 3.0
2016-02-11T10:28:20.907Z
This is kind of off-topic, as converting timestamps is more of a regular programming question than a cryptocurrency specific issue. However, the question is well-written, got an answer quickly, and might be of use to others, so I'll not vote to close.
Murch
<api><timestamp><javascript><bitfinex>
Bitfinex get credits and convert timestamp to JS Date
darksoulsong
# Bitfinex get credits and convert timestamp to JS Date

(Asked by: username_0 on 2016-02-08)

I'm fetching my active credits in BFX and trying to discover when I'll have my funding back. This is a response example:

`/v1/credits`

```
[{
    amount: "294.4316181",
    currency: "USD",
    id: 15778083,
    period: 2,
    rate: "16.816",
    status: "ACTIVE",
    timestamp: "1454846632.0"
}, ...
]

```

But `new Date(1454846632.0)` returns a very old date, what makes me think this timestamp isn't there to be converted into a real date at all.

I am doing something wrong? How can I discover the remaining time of a credit I provided?

**Tags:** api, timestamp, javascript, bitfinex

> **Comments:**
> **username_1**: This is kind of off-topic, as converting timestamps is more of a regular programming question than a cryptocurrency specific issue. However, the question is well-written, got an answer quickly, and might be of use to others, so I'll not vote to close.  

---

## 1 answers

### Answer by username_2 on 2016-02-08. Score: 3 | Accepted answer

The problem is not with the timestamp, it's with your method of converting the timestamp to local time.

As [this SO question](https://stackoverflow.com/questions/4631928/convert-utc-epoch-to-local-date-with-javascript) describes, convert it this way:

```
var dt = new Date(0);
dt.setUTCSeconds(1454846632);
console.log(dt.toString());

```

Which prints `Sun Feb 07 2016 07:03:52 GMT-0500 (EST)`.


---

