Captain James T. Kirk was technically an Admiral in longer than he was Captain of the Enterprise - unless one counts Star Trek Generations. Introduced in Star Trek: The Original Series, Kirk was the first Starfleet hero to command the Starship Enterprise audiences met. Though there have been other Enterprise Captains since, and a few retconned before Kirk, William Shatner's Star Trek icon is still best known as Captain Kirk instead of Admiral Kirk.
Star Trek: The Motion Picture revealed that after the USS Enterprise's historic five-year mission in Star Trek: The Original Series, Captain Kirk was promoted to Rear Admiral and named Chief of Starfleet Operations. Yet Kirk yearned to be back in his beloved Enterprise's Captain's chair, and he engineered events to achieve that goal. Admiral Kirk commanded the USS Enterprise until he was demoted back to Captain. Afterward, Kirk spent the remainder of his life and Starfleet career as Captain, and
Chronologically, James T. Kirk held the rank of Rear Admiral longer than he was a starship Captain. Kirk became a flag officer in 2270 upon completion of the USS Enterprise's five-year mission. Kirk remained Admiral until he was demoted at the end of Star Trek IV: The Voyage Home, in 2286. This means before he resumed his Captaincy, this time on the USS Enterprise-A.

Related
15 Best Star Trek Episodes & Movies Of William Shatner’s Captain Kirk
William Shatner's Captain James T. Kirk remains an iconic figure of popular culture, and these 15 Star Trek episodes and movies illustrate why.
Comparatively, James T. Kirk was originally Captain for 5 years. Kirk became Captain of the USS Enterprise in 2265, taking over for Captain Christopher Pike (Jeffrey Hunter/Anson Mount). After his demotion from Admiral, Kirk remained Captain for another seven years, until his presumed death on the USS Enterprise-B in 2293, as seen in Star Trek Generations' prologue. Therefore, counting both stints together, .
Star Trek Generations muddies the waters as to how long James T. Kirk was actually Captain. When Kirk was caught in the Nexus, the other-dimensional space ribbon plunged him outside normal space and time. Kirk left the Nexus with Captain Jean-Luc Picard (Patrick Stewart) and arrived in the 24th century in 2371 - 78 years after Kirk vanished from the 23rd century. Therefore,

Related
How Long Jean-Luc Picard Was A Star Trek Captain Is Mindblowing
Captain Jean-Luc Picard was a starship captain long before Star Trek: The Next Generation began, making his Starfleet career an incredibly long one.
Of course, had Captain Kirk lived through the end of Star Trek Generations, he wouldn't feel like he was Captain for 90 years. Thanks to the bizarre nature of the Nexus, Kirk reckoned he was only in the fantasy realm for a few minutes before Captain Picard arrived and talked him into helping save Veridian III. To Kirk, it was still 2293, and he was just aboard the USS Enterprise-B commanded by Captain John Harriman (Alan Ruck).
Just as Admiral Picard's son, Jack Crusher (Ed Speleers), told his father that "history remembers you with one less pip," in Star Trek: Picard season 3, . 79 episodes of Star Trek: The Original Series that have been airing on television constantly for nearly 60 years, and three Star Trek movies, depict Jim as Captain Kirk. By contrast, Admiral Kirk was only known as such in four Star Trek movies.
Kirk's own preference and sense of self is his 12 years as Captain of the Enterprise.
Admiral Kirk also has "lost years" that haven't been fully recorded by canon. As alluded to in Star Trek Generations, Admiral Kirk retired from Starfleet at some point after Star Trek: The Motion Picture in the 2270s. Kirk lived in a rustic home in Idaho and raised horses with a woman named Antonia before he grew restless and chose to return to Starfleet in 2383, leading into the events of Star Trek II: The Wrath of Khan. Ultimately, Kirk's own preference and sense of self is his 12 years as Captain of the Enterprise and not his 16 years as Rear Admiral and Chief of Starfleet Operations.