Bitcoin Forum
May 25, 2024, 07:52:00 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: time field on a transaction using javascript  (Read 613 times)
Endlessa (OP)
Sr. Member
****
Offline Offline

Activity: 335
Merit: 250


View Profile
May 24, 2014, 12:43:41 AM
 #1

I'm certain this is a facepalm moment, but I'm trying to convert the json time field on a transaction using javascript and can't figure out wtf I'm doing wrong. .. fml moment

new Date(objectTransaction.time).toUTCString()

returns a date in 1970, obviously this is not correct

please help Smiley
eb3full
VIP
Full Member
*
Offline Offline

Activity: 198
Merit: 101


View Profile
May 24, 2014, 01:20:33 AM
 #2

Is objectTransaction.time a unix timestamp? The Date constructor requires timestamps in milliseconds, so you need to do:

Code:
new Date(objectTransaction.time * 1000).toUTCString()

"With four parameters I can fit an elephant, and with five I can make him wiggle his trunk." John von Neumann
buy me beer: 1HG9cBBYME4HUVhfAqQvW9Vqwh3PLioHcU
Endlessa (OP)
Sr. Member
****
Offline Offline

Activity: 335
Merit: 250


View Profile
May 24, 2014, 03:37:08 AM
 #3

Is objectTransaction.time a unix timestamp? The Date constructor requires timestamps in milliseconds, so you need to do:

Code:
new Date(objectTransaction.time * 1000).toUTCString()

lol I knew it was something stupid Smiley ty Smiley
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!