I want to get the timestamp of the block in Seconds but eosjs library returns it in an iso string format. Is there a way to receive timestamp in seconds or convert the string to seconds?

Example: What I get:

block_time: '2021-03-12T05:45:56.000'

What I want:

block_time in seconds.

1 Answer 1


You can pass block_time string to instantiate Date object. It contains milliseconds, so you need to divide it by 1000 to get seconds.


const block_time = '2021-03-12T05:45:56.000';
const seconds = Math.floor(new Date(block_time) / 1000);



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.