# How to estimate block number at future date/time?

I am creating a smart contract that will allow actions to be taken during a specific time period.

Ideally, I would like to let users know in advance the start block/end block that the contract will be available.

If I had a date in mind (say September 30 at 00:00:00 UTC), is it possible for me to calculate which block will likely be mined at that time? It doesn't have to be exact.

As per My experience, If you know the exact start and end date with time, for an action to be carried out. It easy to implement. For example in solidity,

``````uint256 starttime = 1505217600    // 09/12/2017 @ 12:00pm (UTC)
uint256 endtime = 1505304000     // 09/13/2017 @ 12:00pm (UTC)

// This function will execute only between start time and end time
// now return current time of blockchain in unix timestamp
function _d0 {
require ( now >= startime && now <= endtime );
/*
*/
}
``````

You can convert time to unix timestamp here

Perhaps you could use solidity's time units to achieve what you want:

Suffixes like seconds, minutes, hours, days, weeks and years after literal numbers can be used to convert between units of time where seconds are the base unit and units are considered naively in the following way:

``````    1 == 1 seconds
1 minutes == 60 seconds
1 hours == 60 minutes
1 days == 24 hours
1 weeks == 7 days
1 years == 365 days
``````

Take care if you perform calendar calculations using these units, because not every year equals 365 days and not even every day has 24 hours because of leap seconds. Due to the fact that leap seconds cannot be predicted, an exact calendar library has to be updated by an external oracle.

Or you could use `block.timestamp` in block properties and test for nth block on Sept 30th..

• Solidity 0.5.0 removed the `years` keyword due to complications and confusions about leap years. Commented Jun 10, 2020 at 1:00

We built a little tool for this last year called BlockBucket:

https://blockbucket.io/block-calculator

It works by using the average block times and figuring out how many blocks it will take to get to that time. We've built it to work for most EVM chains.

Let me know if you have any questions :)