RTC integration with Arduino MEGA

If you are connected to the Internet, why don't you get the time from an NTP server?

Something like https://www.arduino.cc/en/Tutorial/LibraryExamples/UdpNtpClient