DateTime Error

Hi all,

I’m trying to build one of these ( for a school project. I’ve been trying to get the DateTime library to work on my Uno (I realize that the Time library replaced it, but I had many more challenges trying to get that to work- and the Garduino code provided uses the DateTime library). I’ve solved a couple errors on my own but I still have one that I can’t figure out.

This is the code:

// DateTime.pde
// example sketch for the DateTime library

#include <DateTime.h>
#include <DateTimeStrings.h>

#define TIME_MSG_LEN  11   // time sync to PC is HEADER followed by unix time_t as ten ascii digits
#define TIME_HEADER  255   // Header tag for serial time sync message

void setup(){
  pinMode(13,OUTPUT); // we flash the LED each second

void  loop(){
  unsigned long  prevtime;
  if( getPCtime()) {  // try to get time sync from pc
    Serial.print("Clock synced at: ");
  if(DateTime.available()) { // update clocks if time has been synced
    digitalWrite(13,LOW);  // first flash the LED
    prevtime =;
    while( prevtime == )  // wait for the second to rollover
    DateTime.available(); //refresh the Date and time properties
    digitalClockDisplay( );   // update digital clock

    // send our time to any app at the other end of the serial port
    Serial.print (TIME_HEADER, uint8_t); // this is the header for the current time

boolean getPCtime() {
  // if time sync available from serial port, update time and return true
  while(Serial.available() >=  TIME_MSG_LEN ){  // time message consists of a header and ten ascii digits
    if( == TIME_HEADER ) {        
      time_t pctime = 0;
      for(int i=0; i < TIME_MSG_LEN -1; i++){   
        char c=;          
        if( c >= '0' && c <= '9'){   
          pctime = (10 * pctime) + (c - '0') ; // convert digits to a number    
      DateTime.sync(pctime);   // Sync Arduino clock to the time received on the serial port
      return true;   // return true if time message received on the serial port
  return false;  //if no message return false

void digitalClockDisplay(){
  // digital clock display of current date and time
  Serial.print(" ");
  Serial.print(" ");
  Serial.print(" ");

void printDigits(byte digits){
  // utility function for digital clock display: prints preceding colon and leading 0
  if(digits < 10)

This is my error:

DateTime.pde: In function 'void loop()':
DateTime:30: error: expected primary-expression before ')' token

I’m a complete noob so thank you for your time and patience!

It is complaining about the "uint8_t" construct on line 30:

    Serial.print (TIME_HEADER, uint8_t); // this is the header for the current time

If you are using Arduino 1.0 or later, try this:


It may or may not work depending on what you intended, but it will probably compile.


Thanks! That provided more errors though..?

C:\Users\huntek3\Desktop\arduino-1.0.2\libraries\DateTime\DateTime.cpp: In member function 'void DateTimeClass::setTime(time_t)':
C:\Users\huntek3\Desktop\arduino-1.0.2\libraries\DateTime\DateTime.cpp:28: error: 'millis' was not declared in this scope
C:\Users\huntek3\Desktop\arduino-1.0.2\libraries\DateTime\DateTime.cpp: In member function 'time_t DateTimeClass::now()':
C:\Users\huntek3\Desktop\arduino-1.0.2\libraries\DateTime\DateTime.cpp:43: error: 'millis' was not declared in this scope

This looks like a "library not ready for Arduino 1.0" problem.

Does it work better if you add:

#include "Arduino.h"

…to the top of the program?


No, the errors remain the same.


At this point I would contact the author of the library and see if he or she can offer advice.

You might also search the forum to see if others have had similar problems with this library.

Best regards,