Arduino uno time library not working

My Arduino time library is imported, and yet it is not recognizing any time functions. My code is

#include "time.h"

void setup() {
   time_t t = now();
   hour(t);

}

void loop() {
  // put your main code here, to run repeatedly:

}

It is giving me an "error line 4 'now' was not declared in this scope time_t t = now();"
If anyone knows how to fix this, help would be greatly appreciated!

Have you first installed the library in the Library Manager? Second, to get the actual time, you need to have an external timekeeping source like GPS, the internet or RTC modules etc.

The include file is now TImeLib.h instead of the older Time.h, because operating systems such as Windows cannot differentiate between the library's TIme.h and the standard c library time.h.

1 Like

Your topic has been moved to a more suitable location on the forum as this has nothing to do with Avrdude, stk500 or Bootloader.

@david_2018 is right. "time.h" and "Time.h" both result in "'now' is not declared in this scope" but "TimeLib.h" result in a successful compilation.

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