We do not come here to visit the interior of the cave which is not accessible to the public but to settle in the meadow opposite at the end of the afternoon and wait for the millions of bats that live there to gio out. When they fly out the cave at nightfall (around 6 p.m.), they form a long discontinuous black cloud. I didn't stay to the end but it seems like it takes more than two hours before all the bats are out. An impressive spectacle that can be observed in other bat caves in Thailand. The best known are in Loei, Phitsanulok and Ratchaburi provinces.
In the morning, at dawn, around 6 a.m., the bats are coming back. So it's up to you, if you want to go there in the morning or in the evening but in general, people go there at nightfall and also enjoy the sunset before leaving. This is part of the tour I recommend on this page.
To go visit Khao Yai Bat Cave, you can also book one of the tours above.