How to display the Date and time on the Dwin display

Hello all,
Can anyone explain how to display the Date and time on the Dwin display?
I'm using NTP Server and ESP32 as my MCU, below is my NTP Server code to get date & time:

#include <WiFi.h>
#include "time.h"

const char* ssid       = "XXXXXXXXXXXXXX";
const char* password   = "***********";

const char* ntpServer = "pool.ntp.org";
const long  gmtOffset_sec = 19800;
const int   daylightOffset_sec = 0;

void printLocalTime()
{
  struct tm timeinfo;
  if(!getLocalTime(&timeinfo)){
    Serial.println("Failed to obtain time");
    return;
  }
  Serial.println(&timeinfo, "%Y %B %d %H:%M:%S, %A");
}

void setup()
{
  Serial.begin(115200);
  
  //connect to WiFi
  Serial.printf("Connecting to %s ", ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
      delay(500);
      Serial.print(".");
  }
  Serial.println(" CONNECTED");
  
  //init and get the time
  configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
  printLocalTime();

  //disconnect WiFi as it's no longer needed
  WiFi.disconnect(true);
  WiFi.mode(WIFI_OFF);
}

void loop()
{
  delay(1000);
  printLocalTime();
}

Thanks in advance.

Do you know how to display anything to the display ?

yes, I started with displaying Integers.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.