I've knitted many of these hats over the years. Reposting it in a shortened format. Original pattern is here - pattern is for charity or personal use only. Dedicated to Natalie who wrote many patterns for the machine knitting community before her untimely death. The original pattern also includes directions for calculating your own hat.
Machine: std gauge machine
Size: baby (toddler : adult)
Cast on 120 (135 : 160) sts EON - I use the slip stitch cast on which can be gathered up later
Knit 10 rows at T3
Bring the remaining needles into work and knit to row 62 (72: 88) in fairisle pattern of your choice (T6)
Knit to row 93 (103 : 119) in a single colour to produce the brim
Knit 1 row T10 (turn row)
Knit to row 125 (135 : 151) in a single colour (T6)
Knit to row 177 (197 : 229) in fairisle
Transfer to EON and knit to row 187 ( 207 : 239) at T3
Break yarn, leaving a long length, and thread through live stitches, or start a new hat with a seperating row of ravel cord.
Gather up both ends, sew side seam, sew the crowns together.