RTC 2.0 how to make it readable to humans

ok I got the UTC from blynk server but how in the world would you convert Unix timestamp to hour min sec and date , I just get a really long number ? RTC widget does not work in sketch. :upside_down_face:

void GetTime() {

  my_h = MyPrintDigits(hour());
  my_m = MyPrintDigits(minute());
  my_s = MyPrintDigits(second());
  my_D = MyPrintDigits(day());
  my_M = MyPrintDigits(month());

  /////////////////////////////////////// Clock /////////////////////////////////////
  String Weekday = dayAsString(weekday());
  Blynk.virtualWrite(V2, Weekday + " " + my_D + " " + my_M);
  Time = my_h + ":" + my_m + ":" + my_s;
  Blynk.virtualWrite(V1, Time);
}

///////////////////////////////////// MyPrintDigits /////////////////////////////////////
String MyPrintDigits(int digits) {
  String new_digits = "";
  if (digits < 10) new_digits += "0";
  new_digits += String(digits);
  return new_digits;
}
///////////////////////////////////// Day of the week  /////////////////////////////////////
String dayAsString(int day) {
  switch (day) {
    case 1: return "Dimanche";
    case 2: return "Lundi";
    case 3: return "Mardi";
    case 4: return "Mercredi";
    case 5: return "Jeudi";
    case 6: return "Vendredi";
    case 7: return "Samedi";
  }
}
2 Likes

thank you for such fast reply, do you use time library ? if so how do you sync the library to blynk server ?

1 Like

I don’t use any extra library.
I use timer included in blynk library.
Don’t forget to add

WidgetRTC rtc;

thank you…:thinking:

1 Like