javascript - Outputting human readable times from timestamps on blockchain.info -


i want parse timestamps json responses blockchain.info's api.

here example snippet https://blockchain.info/api/api_websocket

so if at

"time": 1331300839, 

i try , like

var test = new date(1331300839); test.getfullyear(); 

and results circa 1970. i've tried using date object parse recent bitcoin transactions.. https://blockchain.info/rawaddr/1hy8lsovpit3z4qf7hr2pijxzfhzpsbaek , i'm still getting 1970.

so how human readable output these timestamps?

thanks.

if wanna format date , times, best light-weight library can find out there moment.js

var parsed = moment.unix(1331300839) 

now format moment instance, use format want list: http://momentjs.com/docs/#/displaying/ or use simple yet powerful moment.tostring() or moment.fromnow()

parsed.tostring() // "fri mar 09 2012 14:47:19 gmt+0100"  parsed.fromnow() // "2 years ago" 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -