Block by time
Get a block number by its date
Install
npm i eth-block-timestamp
Usage
import Blocks from 'eth-block-timestamp'
const blocks = new Blocks(
(window as any).ethereum || 'https://mainnet.infura.io/v3/{API_KEY}'
)
const { block, timestamp } = await blocks.getDate('first')
const { block, timestamp } = await blocks.getDate('latest')
const { block, timestamp } = await blocks.getDate('03/20/2020')
const { block, timestamp } = await blocks.getDate('03/20/2020 03:10:00 AM')
const { block, timestamp } = await blocks.getDate('1586618608')