Hi!
I want to use the function strptime from time.h to convert a timestamp to unix time but get the error "implicit declaration of function 'strptime'; did you mean 'strftime'? [-Wimplicit-function-declaration]".
I am using nrf9160dk_nrf9160ns and NCS v1.5.0. And when I google the problem, it says that not all compiler have that function in time.h. Which compiler is use, is it gcc?
main.c:
#include <zephyr.h> #include <sys/printk.h> #include <drivers/uart.h> #include <string.h> #include <time.h> #include "SEGGER_RTT.h" void main(void) { struct tm tm; time_t unixtime; strptime("Wed, 07 Dec 2021 12:14:46 GMT","%a, %e %h %Y %H:%M:%S %Z", &tm); unixtime = mktime(&tm); SEGGER_RTT_printf(0, "%d\n",unixtime); }
Is there any function to easily do the convert?
Thanks! /Ellinor