how to get human readable timestamp through solidity ? I know there is block.timestamp to get the unix time. But i want it in human readable format like Mon Jun 19 11:51:19 IST 2017.
Please suggest.
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.
Sign up to join this communityhow to get human readable timestamp through solidity ? I know there is block.timestamp to get the unix time. But i want it in human readable format like Mon Jun 19 11:51:19 IST 2017.
Please suggest.
I can't really think of a use case for this within an Ethereum contract. When you talk about human readable formats, it seems to me like you're looking to make a user interface.
I would recommend looking into Truffle. It's an excellent framework for building web3
applications, which are essentially just websites that can talk to contracts on the Ethereum blockchain. Then you can just make a web3
call to get block.timestamp
in seconds, and use normal JavaScript to convert it to a human readable format and display it in a browser like Google Chrome, using extensions like Metamask.
For conversion from seconds since the Unix epoch to a readable format with JavaScript, see: https://stackoverflow.com/questions/5416920/timestamp-to-human-readable-format