Trying to Display Time using time.h

I am attempting to get my Uno to read the current time from the laptop it is connected to. I thought including time.h and then using hour() and minute() would work, but I keep getting that they aren't declared. Am I doing something wrong? I included sections of my code where I am using these. Help much appreciated!

#include <genieArduino.h>
Genie genie;
#include <math.h>
#include <time.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2,3);
#define RESETLINE 4

//----------------------------------------

int timeHour;
int timeMin;
int timeMonth;
int timeDay;

//----------------------------------------

timeHour = hour();
    timeMin = minute();
    timeMonth = month();
    timeDay = day();
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,3,timeHour);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,4,timeMin);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,5,timeMonth);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,6,timeDay);

Post the whole program. Read the forum guidelines.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

Please include the entire error message. It is easy to do. There is a button (lower right of the IDE window) called "copy error message". Copy the error and paste into a post in code tags. Paraphrasing the error message leaves out important information.

Those are the only parts of code I added in when it stopped working, so I didn't include it all. It is very long and most of it is irrelevant to the time issues, but here it is.

#include <genieArduino.h>
Genie genie;
#include <math.h>
#include <Time.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2,3);
#define RESETLINE 4

const byte numChars=5;
char receivedChars[numChars];
boolean newData=false;
const byte numCharsVol=5;
char receivedCharsVol[numCharsVol];
boolean newDataVol=false;
long int price=0;
long int delivered=0;
long int cost=0;
int LastChanged;
int difference;
int cost_initial;
int vol=0;
unsigned long startTime;
unsigned long currentTime;
unsigned long chargeTime;
long int hourCharge;
long int minuteCharge;
long int secondCharge;
int timeHour;
int timeMin;
int timeMonth;
int timeDay;

void setup() {
    Serial.begin(9600);
    while(!Serial){
      ;
    }
    mySerial.begin(9600);
    genie.Begin(mySerial);
    pinMode(RESETLINE, OUTPUT);
    digitalWrite(RESETLINE, 1);
    delay(100);
    digitalWrite(RESETLINE, 0);
    delay(3500);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,8,0);
    genie.WriteContrast(10);
    timeHour = hour();
    timeMin = minute();
    timeMonth = month();
    timeDay = day();
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,3,timeHour);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,4,timeMin);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,5,timeMonth);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,6,timeDay);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,7,82);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,11,999);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,12,59);
    delay(1000);
    Serial.println("Charging Ready\n");
    Serial.println("How much charge?");
}
 
void loop() {
   timeHour = hour();
    timeMin = minute();
    timeMonth = month();
    timeDay = day();
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,3,timeHour);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,4,timeMin);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,5,timeMonth);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,6,timeDay);
  if(vol==0){
    getVolume();
  }
  else{
    if(price==0&&newDataVol==false){
    Serial.print("Charge Needed: ");
    Serial.println(vol);
    }
    else{
      recvWithEndMarker();
      showNewData();
    }
  }
  
  if(price>0 && vol>0){
    startTime=millis();
    timeHour = hour();
    timeMin = minute();
    timeMonth = month();
    timeDay = day();
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,3,timeHour);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,4,timeMin);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,5,timeMonth);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,6,timeDay);
  for(delivered=0;delivered<(vol+1);delivered++){
    timeHour = hour();
    timeMin = minute();
    timeMonth = month();
    timeDay = day();
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,3,timeHour);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,4,timeMin);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,5,timeMonth);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,6,timeDay);
    recvWithEndMarker();
    showNewData();
    difference=delivered-LastChanged;
    //Serial.println(LastChanged);
    //Serial.println(delivered);
    //Serial.println(difference);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,1,delivered);
    if(difference==delivered){
      cost = difference*price*0.01L;
      //Serial.println("first one");
    }
    if(difference==0 && difference != delivered){
      cost_initial = cost;
      //Serial.println("second one");
      //Serial.println(cost_initial);
    }
    if(difference>=0 && difference != delivered){
      cost = cost_initial+((difference+1)*price*0.01L);
      //Serial.println("third one");
    }
    //Serial.println(cost);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,2,cost);
    currentTime=millis();
    chargeTime = currentTime-startTime;
    hourCharge = floor(chargeTime/3600000);
    if(hourCharge<1){
      minuteCharge = floor(chargeTime/60000);
    }
    else{
      minuteCharge = (chargeTime-(hourCharge*3600000))/1000;
    }
    if(minuteCharge<1){
      secondCharge = chargeTime/1000;
    }
    else{
      secondCharge = (chargeTime-(minuteCharge*60000))/1000;
    }
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,9,hourCharge);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,10,minuteCharge);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,13,secondCharge);
    delay(300);
  }
    timeHour = hour();
    timeMin = minute();
    timeMonth = month();
    timeDay = day();
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,3,timeHour);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,4,timeMin);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,5,timeMonth);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,6,timeDay);
  delay(30000);
    timeHour = hour();
    timeMin = minute();
    timeMonth = month();
    timeDay = day();
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,3,timeHour);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,4,timeMin);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,5,timeMonth);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,6,timeDay);
  price=0;
  delivered=0;
  cost=0;
  LastChanged=0;
  difference=0;
  cost_initial=0;
  vol=0;
  hourCharge=0;
  minuteCharge=0;
  secondCharge=0;
  newDataVol=false;
  genie.WriteObject(GENIE_OBJ_LED_DIGITS,0,price);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS,1,delivered);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS,2,cost);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS,9,hourCharge);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS,10,minuteCharge);
  genie.WriteObject(GENIE_OBJ_LED_DIGITS,13,secondCharge);
  Serial.println("\nNew Charging Session");
  Serial.println("How much charge?");
    timeHour = hour();
    timeMin = minute();
    timeMonth = month();
    timeDay = day();
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,3,timeHour);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,4,timeMin);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,5,timeMonth);
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,6,timeDay);
  }
  else{
    recvWithEndMarker();
    showNewData();
  }
}

void getVolume(){
  static byte ndx=0;
  char endMarker = '\n';
  char vol_read;

  while(Serial.available()>0 && newDataVol==false){
    vol_read = Serial.read();

    if(vol_read != endMarker){
      receivedCharsVol[ndx]=vol_read;
      ndx++;
      if(ndx>=numCharsVol){
        ndx=numCharsVol-1;
      }
    }
    else{
      receivedCharsVol[ndx]='\0';
      ndx=0;
      newDataVol=true;
    }
  }
  if(newDataVol==true){
    Serial.print("Charge required is ");
    Serial.print(receivedCharsVol);
    Serial.println("0 watt-hours\n");
    vol = atoi(receivedCharsVol);
    //Serial.println(vol);
    Serial.println("How much does it cost?");
  }
}

void recvWithEndMarker(){
  static byte ndx=0;
  char endMarker = '\n';
  char rc;

  while(Serial.available()>0 && newData==false && newDataVol==true){
    rc=Serial.read();

    if(rc != endMarker){
      receivedChars[ndx]=rc;
      ndx++;
      if(ndx>=numChars){
        ndx=numChars-1;
      }
    }
    else{
      receivedChars[ndx]='\0';
      ndx=0;
      newData=true;
    }
  }
}

void showNewData(){
  if(newData==true){
    Serial.print("Price Changed at ");
    Serial.print(delivered);
    Serial.println("0 watt-hours");
    Serial.print("New price is ");
    price = atoi(receivedChars);
    Serial.print(price);
    Serial.println(" cents\n");
    genie.DoEvents();
    genie.WriteObject(GENIE_OBJ_LED_DIGITS,0,price);
    newData = false;
    LastChanged = delivered;
    Serial.println("Has the price changed?");
  }
}

Error Message (exact paths are not accurate because I cannot post my company name online):

Arduino: 1.8.15 (Windows 10), Board: "Arduino Uno"




C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\----\Documents\Arduino\libraries -fqbn=arduino:avr:uno -vid-pid=2341_0043 -ide-version=10815 -build-path C:\Users\--~1\AppData\Local\Temp\arduino_build_772662 -warnings=none -build-cache C:\Users\--~1\AppData\Local\Temp\arduino_cache_204491 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\----\Desktop\change_price_with_serial\change_price_with_serial_3\change_price_with_serial_3.ino

C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\----\Documents\Arduino\libraries -fqbn=arduino:avr:uno -vid-pid=2341_0043 -ide-version=10815 -build-path C:\Users\--~1\AppData\Local\Temp\arduino_build_772662 -warnings=none -build-cache C:\Users\--~1\AppData\Local\Temp\arduino_cache_204491 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\----\Desktop\change_price_with_serial\change_price_with_serial_3\change_price_with_serial_3.ino

Using board 'uno' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr

Using core 'arduino' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr

Detecting libraries used...

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10815 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\standard" "C:\\Users\\--~1\\AppData\\Local\\Temp\\arduino_build_772662\\sketch\\change_price_with_serial_3.ino.cpp" -o nul

Alternatives for genieArduino.h: [ViSi-Genie-Arduino-Library-master@1.5.1 genieArduino-1.5.2@1.5.2]

ResolveLibrary(genieArduino.h)

  -> candidates: [ViSi-Genie-Arduino-Library-master@1.5.1 genieArduino-1.5.2@1.5.2]

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10815 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\standard" "-IC:\\Users\\--\\--\\Documents\\Arduino\\libraries\\genieArduino-1.5.2\\src" "C:\\Users\\--~1\\AppData\\Local\\Temp\\arduino_build_772662\\sketch\\change_price_with_serial_3.ino.cpp" -o nul

Alternatives for SoftwareSerial.h: [SoftwareSerial@1.0]

ResolveLibrary(SoftwareSerial.h)

  -> candidates: [SoftwareSerial@1.0]

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10815 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\standard" "-IC:\\Users\\--\\--\\Documents\\Arduino\\libraries\\genieArduino-1.5.2\\src" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SoftwareSerial\\src" "C:\\Users\\--~1\\AppData\\Local\\Temp\\arduino_build_772662\\sketch\\change_price_with_serial_3.ino.cpp" -o nul

Using cached library dependencies for file: C:\Users\----\Documents\Arduino\libraries\genieArduino-1.5.2\src\genieArduino.cpp

Using cached library dependencies for file: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src\SoftwareSerial.cpp

Generating function prototypes...

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10815 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\standard" "-IC:\\Users\\--\\--\\Documents\\Arduino\\libraries\\genieArduino-1.5.2\\src" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SoftwareSerial\\src" "C:\\Users\\--~1\\AppData\\Local\\Temp\\arduino_build_772662\\sketch\\change_price_with_serial_3.ino.cpp" -o "C:\\Users\\--~1\\AppData\\Local\\Temp\\arduino_build_772662\\preproc\\ctags_target_for_gcc_minus_e.cpp"

"C:\\Program Files (x86)\\Arduino\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\--~1\\AppData\\Local\\Temp\\arduino_build_772662\\preproc\\ctags_target_for_gcc_minus_e.cpp"

Compiling sketch...

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10815 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\standard" "-IC:\\Users\\--\\--\\Documents\\Arduino\\libraries\\genieArduino-1.5.2\\src" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\SoftwareSerial\\src" "C:\\Users\\---~1\\AppData\\Local\\Temp\\arduino_build_772662\\sketch\\change_price_with_serial_3.ino.cpp" -o "C:\\Users\\---~1\\AppData\\Local\\Temp\\arduino_build_772662\\sketch\\change_price_with_serial_3.ino.cpp.o"

C:\Users\----\Desktop\change_price_with_serial\change_price_with_serial_3\change_price_with_serial_3.ino: In function 'void setup()':

change_price_with_serial_3:47:16: error: 'hour' was not declared in this scope

     timeHour = hour();

                ^~~~

change_price_with_serial_3:48:15: error: 'minute' was not declared in this scope

     timeMin = minute();

               ^~~~~~

C:\Users\----\Desktop\change_price_with_serial\change_price_with_serial_3\change_price_with_serial_3.ino:48:15: note: suggested alternative: 'init'

     timeMin = minute();

               ^~~~~~

               init

change_price_with_serial_3:49:17: error: 'month' was not declared in this scope

     timeMonth = month();

                 ^~~~~

change_price_with_serial_3:50:15: error: 'day' was not declared in this scope

     timeDay = day();

               ^~~

C:\Users\----\Desktop\change_price_with_serial\change_price_with_serial_3\change_price_with_serial_3.ino: In function 'void loop()':

change_price_with_serial_3:64:15: error: 'hour' was not declared in this scope

    timeHour = hour();

               ^~~~

change_price_with_serial_3:65:15: error: 'minute' was not declared in this scope

     timeMin = minute();

               ^~~~~~

C:\Users\----\Desktop\change_price_with_serial\change_price_with_serial_3\change_price_with_serial_3.ino:65:15: note: suggested alternative: 'init'

     timeMin = minute();

               ^~~~~~

               init

change_price_with_serial_3:66:17: error: 'month' was not declared in this scope

     timeMonth = month();

                 ^~~~~

change_price_with_serial_3:67:15: error: 'day' was not declared in this scope

     timeDay = day();

               ^~~

Multiple libraries were found for "genieArduino.h"

 Used: C:\Users\----\Documents\Arduino\libraries\genieArduino-1.5.2

 Not used: C:\Users\----\Documents\Arduino\libraries\ViSi-Genie-Arduino-Library-master

Using library genieArduino-1.5.2 at version 1.5.2 in folder: C:\Users\----\Documents\Arduino\libraries\genieArduino-1.5.2 

Using library SoftwareSerial at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial 

exit status 1

'hour' was not declared in this scope


I am now just trying a simple program to get the date and time from the pc. I have Time.h installed and am trying to use the TimeSerial example included in that. I am confused on this example even. Can anyone explain a little better? What do I need to enter in the Serial Monitor? Will this actually display the current date and time or just a date and time from an inputted reference?

/* 
 * TimeSerial.pde
 * example code illustrating Time library set through serial port messages.
 *
 * Messages consist of the letter T followed by ten digit time (as seconds since Jan 1 1970)
 * you can send the text on the next line using Serial Monitor to set the clock to noon Jan 1 2013
 T1357041600  
 *
 * A Processing example sketch to automatically send the messages is included in the download
 * On Linux, you can use "date +T%s\n > /dev/ttyACM0" (UTC time zone)
 */ 
 
#include <TimeLib.h>

#define TIME_HEADER  "T"   // Header tag for serial time sync message
#define TIME_REQUEST  7    // ASCII bell character requests a time sync message 

void setup()  {
  Serial.begin(9600);
  while (!Serial) ; // Needed for Leonardo only
  pinMode(13, OUTPUT);
  setSyncProvider( requestSync);  //set function to call when sync required
  Serial.println("Waiting for sync message");
}

void loop(){    
  if (Serial.available()) {
    processSyncMessage();
  }
  if (timeStatus()!= timeNotSet) {
    digitalClockDisplay();  
  }
  if (timeStatus() == timeSet) {
    digitalWrite(13, HIGH); // LED on if synced
  } else {
    digitalWrite(13, LOW);  // LED off if needs refresh
  }
  delay(1000);
}

void digitalClockDisplay(){
  // digital clock display of the time
  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.print(" ");
  Serial.print(day());
  Serial.print(" ");
  Serial.print(month());
  Serial.print(" ");
  Serial.print(year()); 
  Serial.println(); 
}

void printDigits(int digits){
  // utility function for digital clock display: prints preceding colon and leading 0
  Serial.print(":");
  if(digits < 10)
    Serial.print('0');
  Serial.print(digits);
}


void processSyncMessage() {
  unsigned long pctime;
  const unsigned long DEFAULT_TIME = 1357041600; // Jan 1 2013

  if(Serial.find(TIME_HEADER)) {
     pctime = Serial.parseInt();
     if( pctime >= DEFAULT_TIME) { // check the integer is a valid time (greater than Jan 1 2013)
       setTime(pctime); // Sync Arduino clock to the time received on the serial port
     }
  }
}

time_t requestSync()
{
  Serial.write(TIME_REQUEST);  
  return 0; // the time will be sent later in response to serial mesg
}

The sketch is looking for a 'T' followed by the time, in seconds, commonly referred to as unix time or epoch time.

Go here: Unix Time Stamp - Epoch Converter
and the copy/paste that into Serial Monitor with a 'T' in front of it

I had tried that and it still wasn't printing anything

Is the Serial Monitor set to 9600 baud? Have to selected a line ending?
Pasting this into the Serial Monitor: T1626366046
should get you Thu Jul 15 2021 16:20:46 GMT+0000

:woman_facepalming:t2: Working now, not sure why it wasn't before. Thank you @blh64 !!

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