It completely depends on your objective.
If all you want is to learn basic things e.g. how to order a beer in a bar or how to count until 10, one hour should be enough. For example, Specific Course: Spanish to Stay Afloat is a programme designed to be covered in around 25 hours of classes.
However, if your goal is to achieve an upper-intermediate level of Spanish, i.e. to get to at least B2 level, you will have to dedicate quite some time. The estimated number of hours of classes you need to cover the material from A1 level is 60h, A2- 120h, B1- 180h and B2- 180h. This way, if your objective is to get to B2 level, you will need around 540h of classes. As a reference, if you want to have 2 hours of classes per week, in order to meet this target you will need around 5 years.
Of course it also depends on other factors, e.g. your mother tongue, your knowledge of other foreign languages, if you already live in Spain, if you do homework regularly, if you practice Spanish outside the classroom, etc.
The minimum commitment I require is one month.