February has 28 days - 29 in a leap year.
All the rest have thirty-one except February alone which has twenty-eight;
Except on every fourth year, when it has 29;
Except on years divisible by 100, when it has 28 again;
Unless the year is also divisible by 1000, when it's back to 29.
Unless the year is also divisible by 400, when it's back to 29.
Thirty days has September,
April, June, and November,
All the rest have thirty-one except February,
Which has four and twenty-four,
'til leap year gives it one day more.1 - 3 lines of the rhyme at the end are utterly pointless as it's much easier to just remember that leap years are actually a thing.
2 - The fact that it rhymes doesn't help you remember which months you're talking about. It could quite easily be, "30 days hath September; October, November, December" and it would still rhyme but be wrong.
I was taught:
Thirty Days has September,
April, June and November.
All the rest have Thirty One;
Except February, it's a different one!