简体   繁体   中英

Getting date/time from Mt. Gox's “now” value using socket.io?

I connected to https://socketio.mtgox.com/mtgox using socket.io ( https://socketio.mtgox.com/socket.io/socket.io.js ), and it returned an object that looks like this:

{ 
    exchange: 'mtgox',
    buy: 106.54693,
    sell: 106.99653,
    last: 106.54693,
    vol: 57734.68992687,
    now: 1371584138359638,
    _id: 51c0b68ab3067d631c000002
}

I'm looking for the time and date of the event. There is now: , which appears to be Timestamp, but new Date(1371584138359638); returns Wed Oct 09 45433 05:59:19 GMT-0400 (EDT)

Year 45,433 suggests I'm wrong.

I checked out https://en.bitcoin.it/wiki/MtGox/API/Streaming#Depth , and now: appears in the object, but is not described in the description below.

Any ideas/suggestions?

这是Unix纪元时间戳,以微秒为单位(0为1/1/1970 00:00:00 UTC)

It's in microseconds, and JavaScript uses milliseconds. Divide by 1000.

var dt = new Date(1371584138359638 / 1000);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM