Magnetic field is observed in many planets, stars, and galaxies. It is also present in the intergalactic environment. The generation of magnetic field in these astrophysical objects has been a major theoretical puzzle. The magnetic fields in these systems is primarily dipolar, yet highly time-dependent with strong presence of quadruple and other higher moments. The polarity of the dipole is known to reverse in solar dynamo and geodynamo. For the Sun, the reversal is almost periodic with 22 year cycle. However for the Earth, paleomagnetic data reveals that its polarity reverses after random time intervals. During some period of geological time, the magnetic field has been observed to maintain orientation for tens of millions of years, while at some other times, reversals have taken place within a span of 50,000 years. The last reversal of the geodynamo took place around 780,000 years ago. The above mentioned phenomena make the whole field very exciting, and efforts are being made to understand its dynamics using numerical simulations, experiments, analytical models, astrophysical observations, etc.