How I can calculate Estimated Confirmation Duration
or
Can someone give me a formula to calculate Estimated Confirmation Duration of a pending transaction like etherscan.io do?
There is no formula.
You are waiting for a miner to pick up your transaction and include it in a block. They are under no obligation to that. They are financially incentivized to do that by the gasPrice
you offered them. If it's taking too long, then offer isn't good enough.
The best you can do is compare to historical norms for similarly-priced transactions. As Nikita pointed out, EthGasStation reports such statistics. It will be a curve, with some completing faster than others.
In a situation like yours with a stalled transaction, you can't be sure it won't mine. You would want to be sure of that before you, say, send it again with a higher gas price.
Have a look over here for a way to get a confirmation that you have cancelled it. Canceling / overwriting a pending transaction using geth JSON RPC
Hope it helps.
At EthGasStation.info, they have this calculator. On youtube you can find many tutorials how to properly use this tool, although it should be self explanatory.