Thanks for the explanation. I'm trying to understand it per the rules given here: http://www.russianlessons.net/grammar/nouns_genitive.php but I can't
Oh boy... I'd be confused too, were I not a native speaker. In any case, "время" is a bit of an exceptional noun, which does not follow the standard pattern described there.
So, it's время (nominative and accusative), времени (genitive, dative, prepositional) and временем (instrumental).
I think this is an example of the temporal "for" use of на described on alphadictionary:
https://www.alphadictionary.com/rusgrammar/for.html (seach temporal)