user36753: #include <ESP8266WiFi.h>
#include <time.h>

const char* ssid = "";
const char* password = "";
int timezone = 3;
int dst = 0;

void setup() {
  Serial.begin(115200);
  Serial.setDebugOutput(true);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.println("\nConnecting to WiFi");
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(1000);
  }
  configTime(timezone * 3600, dst * 0, "pool.ntp.org", "time.nist.gov");
  Serial.println("\nWaiting for time");
  while (!time(nullptr)) {
    Serial.print(".");
    delay(1000);
  }
  Serial.println("");
}

void loop() {
  time_t now = time(nullptr);
  Serial.println(ctime(&now));
  delay(1000);
}

This is my code, but it shows the time like this: Sun Jul 23 15:21:12 2017. But what I want it to do is to only show the current hour, not everything.
Is it possible to do that?

user13432: The easiest way is to use the standard function localtime() or gmtime() and the struct tm. 
void loop() {
  time_t now;
  struct tm * timeinfo;
  time(&now);
  timeinfo = localtime(&now);  
  Serial.println(timeinfo->tm_hour);
  delay(1000);
}


36753: <pre><code>#include &lt;ESP8266WiFi.h&gt;
#include &lt;time.h&gt;

const char* ssid = "";
const char* password = "";
int timezone = 3;
int dst = 0;

void setup() {
  Serial.begin(115200);
  Serial.setDebugOutput(true);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.println("\nConnecting to WiFi");
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(1000);
  }
  configTime(timezone * 3600, dst * 0, "pool.ntp.org", "time.nist.gov");
  Serial.println("\nWaiting for time");
  while (!time(nullptr)) {
    Serial.print(".");
    delay(1000);
  }
  Serial.println("");
}

void loop() {
  time_t now = time(nullptr);
  Serial.println(ctime(&amp;now));
  delay(1000);
}
</code></pre>

<p>This is my code, but it shows the time like this: Sun Jul 23 15:21:12 2017. But what I want it to do is to only show the current hour, not everything.
Is it possible to do that?</p>
 13432: <p>The easiest way is to use the standard function <a href="http://www.cplusplus.com/reference/ctime/localtime/" rel="nofollow noreferrer">localtime()</a> or <a href="http://www.cplusplus.com/reference/ctime/gmtime/" rel="nofollow noreferrer">gmtime()</a> and the <a href="http://www.cplusplus.com/reference/ctime/tm/" rel="nofollow noreferrer">struct tm</a>. </p>

<pre><code>void loop() {
  time_t now;
  struct tm * timeinfo;
  time(&amp;now);
  timeinfo = localtime(&amp;now);  
  Serial.println(timeinfo-&gt;tm_hour);
  delay(1000);
}
</code></pre>
