• Support
  • mktime() and timegm() - error

Hello, anyone tried to use either of these functions (I just need a UTC time)
//time_t utctime = mktime(ptm);
time_t utctime = timegm(ptm);
Both of them generate warning: implicit declaration of function ‘timegm’. I tried to add CONFIG_DATE_TIME=y to prj.conf, but I also got an error

41: warning: attempt to assign the value ‘y’ to the undefined symbol DATE_TIME
Thank you !

DATE_TIME is a Nordic library

I think the time header is (off the top of my head): <zephyr/sys/time.h>

    jaredwolff Thank you!. I got it working by #include <zephyr.h>, #include <time.h>, this code compiles now :

        time_t mytime;
        struct tm  ptm;
        time ( &mytime );    // Get local time in time_t
        gmtime_r ( &mytime, &ptm ); // Find out UTC time
    Terms and Conditions | Privacy Policy