void ntpTime()
 {
      int nt=0;
  while(!timeClient.update()) {
    // Serial.println("NTP");
    timeClient.forceUpdate();
    nt++;
    if(nt>2)return;
  }
  // The formattedDate comes with the following format:
  // 2018-05-28T16:00:13Z
  // We need to extract date and time
 // formattedDate = timeClient.getFormattedDate();
String formattedTime =timeClient.getFormattedTime();
  Serial.println(formattedTime);
// getDay
//getHours
//getMinutes
//getSeconds
//getFormattedTime 
// formattedDate =timeClient.getFormattedDate();
 // int splitT = formattedDate.indexOf("T");
//  dayStamp = formattedDate.substring(0, splitT);
//  Serial.println(timeClient.getDay());

  // Extract time
 // timeStamp = formattedDate.substring(splitT+1, formattedDate.length()-1);
 Serial.println("ntp");
  Serial.println(timeClient.getEpochTime());
   stamp.getDateTime(timeClient.getEpochTime());
//EpochTime=timeClient.getEpochTime();
  // забираем вот так
//  Serial.println(stamp.year);
//  Serial.println(stamp.month);
 // Serial.println(stamp.day);
 // Serial.println(stamp.hour);
 // Serial.println(stamp.minute);
 // Serial.println(stamp.second);
 // Serial.println(stamp.dayOfWeek);
CurrentHour = stamp.hour;
  CurrentMin  = stamp.minute;
  CurrentSec  = stamp.second;
 tHour = CurrentHour ;
  tMin = CurrentMin;



 mon=stamp.month;
 date=stamp.day;
 dow=stamp.dayOfWeek;
 if(dow==0){dow=7;}
 years=stamp.year;



 
String timeserv=formatTimeDigits(stamp.hour,stamp.minute); 
String dataserv=formatDateDigits(stamp.day, stamp.month, stamp.year);
Serial.println(timeserv);
Serial.println(dataserv);
}

char *formatTimeDigits(int hour, int minute)
{
char *time_str = new char[5];
time_str[0] = '0' + (hour / 10);
time_str[1] = '0' + (hour % 10);
time_str[2] = ':';
time_str[3] = '0' + (minute / 10);
time_str[4] = '0' + (minute % 10);
time_str[5] = '\0';

return time_str;
}
char *formatDateDigits(int date, int mounth, int year)
{
char *date_str = new char[9];

date_str[1] = '0' + (date % 10);
date_str[2] = '/';
date_str[0] = '0' + (date / 10);
date_str[3] = '0' + (mounth / 10);
date_str[4] = '0' + (mounth % 10);
date_str[5] = '/';
date_str[6] = '0' + ((year % 100) / 10);
date_str[7] = '0' + (year % 10);
date_str[8] = '\0';

return date_str;
}
