1 // Date and time functions using just software, based on millis() & timer
10 // following line sets the RTC to the date & time this sketch was compiled
11 RTC.begin(DateTime(__DATE__, __TIME__));
15 DateTime now = RTC.now();
17 Serial.print(now.year(), DEC);
19 Serial.print(now.month(), DEC);
21 Serial.print(now.day(), DEC);
23 Serial.print(now.hour(), DEC);
25 Serial.print(now.minute(), DEC);
27 Serial.print(now.second(), DEC);
30 Serial.print(" seconds since 1970: ");
31 Serial.println(now.unixtime());
33 // calculate a date which is 7 days and 30 seconds into the future
34 DateTime future (now.unixtime() + 7 * 86400L + 30);
36 Serial.print(" now + 7d + 30s: ");
37 Serial.print(future.year(), DEC);
39 Serial.print(future.month(), DEC);
41 Serial.print(future.day(), DEC);
43 Serial.print(future.hour(), DEC);
45 Serial.print(future.minute(), DEC);
47 Serial.print(future.second(), DEC);