How do I use ZF2 I18n currencyformatter to format bitcoin?

+1 vote
Bitcoin allows 8 decimal places (123.45678912).

How can I use ZF2 I18n currency formatter to format a bitcoin amount with the full 8 decimal places instead of just cutting it short to 2 decimal places?
Sep 10, 2018 in Blockchain by slayer
• 29,050 points
32 views

1 answer to this question.

0 votes

From ZF2's documentation at http://framework.zend.com/manual/2.3/en/modules/zend.i18n.view.helpers.html

I found the following link:

http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#details

If you scroll down to the decimal format and significant digits sections, you'll see the answer. I ended up doing this for my code to represent BTC:

$cur = getCurrency();

$this->plugin("currencyformat")->setCurrencyCode($cur);

if($cur == "BTC"):
    $this->plugin("currencyformat")->setCurrencyPattern('@############### ¤');
endif;

The '@' means display at least one signification digit. The 15 '#'s plus the '@' means the maximum amount of significant digits to show is 16. The '¤' will display the currency at the end of the number.

answered Sep 10, 2018 by digger
• 27,640 points

Related Questions In Blockchain

0 votes
1 answer

How do I use hyperledger fabric blockchain to build my own application?

To use fabric I would recommend you ...READ MORE

answered May 16, 2018 in Blockchain by Johnathon
• 9,080 points
79 views
+1 vote
1 answer

Hyperledger - How can I use transaction certificates to enforce privacy?

The transaction certificates don't actually address privacy ...READ MORE

answered Apr 17, 2018 in Blockchain by Perry
• 17,020 points
122 views
0 votes
1 answer
0 votes
1 answer

How do I send back ethers to the sender of the tokens in a smart contract?

Whenever a smart contract receives ether via ...READ MORE

answered May 30, 2018 in Blockchain by Perry
• 17,020 points
361 views
0 votes
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured by TLS encryption in hashgraph architecture-hashgraph, ...READ MORE

answered Aug 6, 2018 in Blockchain by ariaholic
• 7,340 points
75 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
140 views
0 votes
1 answer
0 votes
1 answer

How i can use nodejs to watch transactions in bitcoin network?

you can use  const Socket = require('blockchain.info/Socket'); const mySocket ...READ MORE

answered Jul 9, 2018 in Blockchain by digger
• 27,640 points
46 views
0 votes
1 answer

How to use bitcoin price as place holder in php?

You can do it by providing an ...READ MORE

answered Aug 21, 2018 in Blockchain by digger
• 27,640 points
39 views