given a time_t variable, how do I get its components e.g month day , hour etc

Thank you

The time library has a breaktime function which changes time_t into a tm_elements structure which has all you need.

Pete

Here's an example:

#include <Time.h>

// Convert time_t to a date string
void make_datestring(time_t t,char *ds)
{
  tmElements_t tm;
  
  breakTime(t, tm);
  sprintf(ds,"%02d%02d%02d %02d:%02d:%02d",
      tm.Year+1970-2000,tm.Month,tm.Day,
      tm.Hour,tm.Minute,tm.Second);
  
}

Pete

Try the standard function gmtime().