Problem with now(); function

uint8_t Encd (uint8_t val){
	uint8_t t = 0;                // make into two separate digits
	t = ((val / 10) << 4) + (val % 10);
	return t;
}

//===============================
void SetTimeDate(){
  
  time_t now(); 
  TimeDate[6] = year();
    Serial.print("   year:  ");
    Serial.println(TimeDate[6]);
  TimeDate[5] = month();
    Serial.print("   month:  ");
    Serial.println(TimeDate[5]);
  TimeDate[4] = day();
    Serial.print("   day:  ");
    Serial.println(TimeDate[4]);
  TimeDate[2] = hour();
    Serial.print("   hour:  ");
    Serial.println(TimeDate[2]);
  TimeDate[1] = minute();
    Serial.print("   minute:  ");
    Serial.println(TimeDate[1]);

  for(int i=0; i<=6;i++){	
    if(i==3)                           	    // point to the day of week
      	i++;                                // then skip over it
	TimeDate[i] = Encd(TimeDate[i]);
    	digitalWrite(rtccs, LOW);
	SPI.transfer(i+0x80);                 // sets MSB for Write
    	SPI.transfer(TimeDate[i]);            
	delay(1);
	digitalWrite(rtccs, HIGH);
	}
}//end ----------------SetTimeDate

The issue is, now(); only seems to return 01-01-1970. What gives? Does this not return seconds SINCE 1970??

What gives? Does this not return seconds SINCE 1970??

It returns whatever time the RTC that backs it up says that it is.

So it's not like the now() function in Excel? I thought that this gives PC time. I'm trying to load the DS3234 from a base time and then every once in a blue moon go out and get it from NIST. The DS3234 is supposedly accurate to about 2 seconds/month.

I had this feature working setting it from NIST but then it seemed to slow the rest of the code down by a lot, so I argued why do I need to update it so often?

Just FYI, Paul, your TIME examples with the Teensy were very helpful. I'm working with an ESP32-Thing and wish I was a little sharper on Unix development environments since the Arduino port of this chip is limited to one processor. I'm hoping by the time I approach completion someone solves some of the other "holes" in the Arduino port. I can tell you though, their SPI library works great, I'm driving a 5" touch display using the Resistive RA8875 built in. Gave up on the GS1680 Capacitive. I can also tell you that RA8875 not tri-stating the MISO line is a pisser! Kind of rough when you're trying your DS3234 SPI stuff.

Bob M.

PC's have a hardware RTC. If you want now() to return an RTC value you have to designate it as a sync provider.