Use a timer which is reset at the zero crossing of any phase of them.
correct time if there's no phase problem must be
50Hz==> 20ms
we have 2 crossing per cycle so 20ms/2=10ms
we have 3 phases so 10ms/3==>3.33 ms must be the time between each phase zero crossing and the next for correct phase.
This is my idea , it may be wrong. think of it 1st