Actually, from Kyoto it is less than 2 hours and costs nothing if you have a JR Rail Pass. There are occasional direct trains and several others that would require a stop and change at Shin-Osaka. From Osaka it takes almost as long since you need to get out to Shin-Osaka station on local lines or the subway.
With an early start, you could get to Miyajima for the morning, return to Hiroshima for the afternoon and catch a late train back to Kyoto/Osaka. In the July heat/humidity, that will make for one looong, tiring day.