Bitcoin Forum
September 27, 2018, 10:48:09 PM *
News: ♦♦ New info! Bitcoin Core users absolutely must upgrade to previously-announced 0.16.3 [Torrent]. All Bitcoin users should temporarily trust confirmations slightly less. More info.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: time field on a transaction using javascript  (Read 521 times)
Endlessa
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
1538088489
Hero Member
*
Offline Offline

Posts: 1538088489

View Profile Personal Message (Offline)

Ignore
1538088489
Reply with quote  #2

1538088489
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1538088489
Hero Member
*
Offline Offline

Posts: 1538088489

View Profile Personal Message (Offline)

Ignore
1538088489
Reply with quote  #2

1538088489
Report to moderator
1538088489
Hero Member
*
Offline Offline

Posts: 1538088489

View Profile Personal Message (Offline)

Ignore
1538088489
Reply with quote  #2

1538088489
Report to moderator
1538088489
Hero Member
*
Offline Offline

Posts: 1538088489

View Profile Personal Message (Offline)

Ignore
1538088489
Reply with quote  #2

1538088489
Report to moderator
eb3full
VIP
Full Member
*
Offline Offline

Activity: 198
Merit: 100


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
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:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!