In Europe the Italian War of 1859 had several battles with one or more monarchs present and more or less commanding their forces and taking the chance that if things went wrong they might have to fight enemies with guns or swords.
At the Battle of Magenta 4 June 1859 King Victor Emmanuel II of Sardinia and French Emperor Napoleon III were present.
https://en.wikipedia.org/wiki/Battle_of_Magenta1
At the Battle of Solferino 24 June 1859 King Victor Emmanuel II of Sardinia and French Emperor Napoleon III and Austrian Emperor Franz Josef were present.
It was the last major battle in world history where all the armies were under the personal command of their monarchs.2
https://en.wikipedia.org/wiki/Battle_of_Solferino3
In Africa, Sultan Abd ar-Rahman Gaourang II of Bagirmi (reigned 1885-1918) and the famous warlord Rabih az-Zubair (c. 1842-1900) lead their armies in several battles.
https://en.wikipedia.org/wiki/Gaourang_II_of_Bagirmi4
https://en.wikipedia.org/wiki/Rabih_az-Zubayr5
Rabih invaded and conquered Bagirmi in 1893. Rabih then invaded the large though declining empire of Bornu in 1893. He conquered and ruled Bornu for years and modernized the government.
Rabih was sufficiently recognized by European powers that in 1898-1900 France sent three separate invasion forces against him. The Foureau-Lamy Mission marched south from Algeria, the Voulet-Chanoine Mission marched east from Senegal, and the Bretonnet and Gentil Missions moved north from the French Congo.
At the Battle of Togbao July 17, 1899 the Bretonnet Mission with 5 Frenchmen, 66 African soldiers, and Sultan Abd ar-Rahman Gaourang II with 400 Bagirmi warriors fought Rabih with 2,700 riflemen and 10,000 lancers and bowmen. Gauorang was wounded but escaped with most of his men and the Bretonnet Mission was wiped out. Three cannon were captured by Rabih.
https://en.wikipedia.org/wiki/Battle_of_Togbao6
Rabih repulsed the Gentil expedition with 344 soldiers and 5 cannons at Kouno on August 16, 1899.
Gentil ordered now to attack the palissade with a bayonet assault, that was repelled after hard fighting by Rabih in person with only a few hundred men still resisting around him.
https://en.wikipedia.org/wiki/Battle_of_Kouno7
The Foureau-Lamy Mission and the remains of the Voulet-Chanoine Mission under Paul Joalland united in March 1900 and captured the village of Kousseri from Rabih on 3 March. The Gentile mission arrived on April 21 and on April 22 Rabih fought the French at the Battle of Kousseri.
There were about 700 French soldiers plus Sultan Gaourang II with 600 riflemen and 200 cavalry on one side and 10,000 infantry and cavalry with firearms plus numerous auxiliaries with lances and bows on Rabih's side. Rabih was defeated and killed while trying to flee.
https://en.wikipedia.org/wiki/Battle_of_Kouss%C3%A9ri2
Thus the last European monarch to fight, or at least command, in battle must have been in or after 1859, and the last monarch in the world to to fight, or at least command, in battle must have been on 22 April 1900 or later.