This seems to come up every now and again and I needed to do this myself so here's an Arduino Sketch and a Visual Basic program to synchronize the Arduino clock (DS1307) to the P.C. clock. The VB program is in Visual Studio 2012 express but should work in any of the later releases as well - I've tried it in VS2017 and all OK.
It's self explanatory (I think) and looks like this.
Hope it's useful to someone.
BTW, the serial monitor can't be running at the same time and if you wish to compile the sketch then you need to disconnect the VB program.
For any IoT type devices that have internet connectivity, you can get the time direct from an internet time server quite simply.
This gives the details needed to set up a request frame (just a lower case c padded with 47 space characters) and interpret the reply.
You could use a local server or eg. pool.ntp.org
I use NTP whenever I use a Wemos or other 8266 based board. However, this is a Nano setup with one of the US$2, I²C, DS1307 + 24C32 memory on board. It was easier to write the code than mess about adding setup buttons and code.
I use NTP whenever I use a Wemos or other 8266 based board. However, this is a Nano setup with one of the US$2, I²C, DS1307 + 24C32 memory on board. It was easier to write the code than mess about adding setup buttons and code.