NTP is the proven way of getting time remotely. NTP libraries, like @Marcel denotes, is making UDP connections to a server with an interval. So you do not need to do any polling to the server before using it.
Here is the usage of an NTP library with a one-hour offset and one minute refresh interval:
#include <NTPClient.h>
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#define NTP_OFFSET 60 * 60 // In seconds
#define NTP_INTERVAL 60 * 1000 // In miliseconds
#define NTP_ADDRESS "europe.pool.ntp.org"
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, NTP_ADDRESS, NTP_OFFSET, NTP_INTERVAL);
void setup(){
timeClient.begin();
}
void loop() {
timeClient.update();
}
To get a timestamp or formatted time anytime you want, use the functions:
String formattedTime = timeClient.getFormattedTime();
unsigned long epcohTime = timeClient.getEpochTime();