This library

The DateTime library included in the dice support package was extracted from the RTClib by Adafruit with slight adaptions. This page aims to provide a quick reference to ‘everyday’ use cases rather than a full documentation which can be found on the RTClib doxigen pages.
DateTime – documentation
TimeSpan – documentation

To use this library

#include "DateTime.h"

Create a DateTime object

// By epoch time (seconds since 1.1.1970)
DateTime t_dateByEpochTime(1736294400);

// By date & time components (yyyy,mm,dd,hh,mm,ss)
DateTime t_dateByComponents( 2025, 8, 1, 1, 10, 00);

// from RTC
DateTime t_dateFromRTC =;	



Examples can be found in the Arduino IDE menu:
File -> Examples -> DateTime-> ...

1) This example sets the RTC and writes a timestamp in ISO format into file in SerialFlash and SD Card.

void setup()

void loop () 
{ }

2) another example.

void setup()
  while (!Serial) { yield(); }

void loop () 
{ }

DateTime library compatibility

Further reads

Find more details about the DateTime, RTC, TimeSpan, c_str(), SerialFlash and SD library time functions here

DateTime class

TimeSpan class