Short gamma-ray bursts (SGRBs) have been observed for decades, but it is still not clear what is causing these powerful explosions. One of the most popular models involves the merger of two neutron stars or of a neutron star (NS) with a black hole (BH). After the merger, an accretion disk may be formed and launch a relativistic jet which may be powered by magnetic fields. Recent observations have cast some doubts on this model due to the extended duration of some of the observed SGRBs, which seem to require a long-lived central engine, a magnetar. In both models magnetic fields play therefore a very important role and an accurate description of the magnetic field evolution during and after the merger is required. I will discuss how general relativistic magnetohydrodynamic simulations can help us to study both scenarios and possibly unveil the central engine of SGRBs.