Moderator: igrr
String getTime() {
WiFiClient client;
while (!!!client.connect("google.com", 80)) {
Serial.println("connection failed, retrying...");
}
client.print("HEAD / HTTP/1.1\r\n\r\n");
while(!!!client.available()) {
yield();
}
while(client.available()){
if (client.read() == '\n') {
if (client.read() == 'D') {
if (client.read() == 'a') {
if (client.read() == 't') {
if (client.read() == 'e') {
if (client.read() == ':') {
client.read();
String theDate = client.readStringUntil('\r');
client.stop();
return theDate;
}
}
}
}
}
}
}
}
That will return a String like "Thu, 15 Oct 2015 08:57:03 GMT"