programowanie:esp32:time

Różnice

Różnice między wybraną wersją a wersją aktualną.

Odnośnik do tego porównania

Nowa wersja
Poprzednia wersja
programowanie:esp32:time [2024/08/12 23:54] – utworzono sasesprogramowanie:esp32:time [2024/08/28 21:30] (aktualna) sases
Linia 2: Linia 2:
 #include "time.h" #include "time.h"
  
-configTime(72000, "adres_pierwszego_serwera_ntp", "ntp.certum.pl"); //ustawienie - serwer NTP + co???+configTime(offet_strefy_czasowej=3600offset_czasu_letniego=3600, "adres_pierwszego_serwera_ntp", "ntp.certum.pl");
  
 // pobranie aktualnego czau // pobranie aktualnego czau
Linia 10: Linia 10:
   Serial.println("Failed to obtain time");   Serial.println("Failed to obtain time");
 } }
 +else {
 +  time(&now);
 +  Serial.print("   Unixtime: ");
 +  Serial.println(now);  // czas uniksowy
  
-time(&now); +  char buffer[26]; 
-Serial.print("   Unixtime: "); +  strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", &timeinfo); 
-Serial.println(now); // czas uniksowy +  Serial.print("   Datetime: "); 
- +  Serial.println(buffer); 
-char buffer[26]; + }
-strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", &timeinfo); +
-Serial.print("   Datetime: "); +
-Serial.println(buffer);+
 </code> </code>
  
Linia 27: Linia 28:
   Serial.println("Failed to obtain time");   Serial.println("Failed to obtain time");
 } }
-time(&now);+else { 
 +  time(&now);
              
-Serial.println(now);+  Serial.println(now); 
 +}
 </code> </code>
  • programowanie/esp32/time.1723499645.txt.gz
  • ostatnio zmienione: 2024/08/12 23:54
  • przez sases