Problem with DS3234

Hello guys.
I have a problem with DS3234(Real Time Clock). I'm using DeadOn RTC - DS3234 Breakout by sparkfun. I made this sketch RTC_SPI_for_setup.
It doesn't work well. It shows lots of error like this.
2014/00/05 16:47:00
2014/11/05 04:47:44
2014/00/05 16:47:04
2014/11/05 04:47:46
2014/00/05 16:47:04
2014/11/05 04:47:48
2014/00/05 16:47:00
2014/11/05 04:47:50
2014/00/05 16:47:00
2014/11/05 16:47:52
2014/11/05 16:47:53
2014/11/05 16:47:54
2014/11/05 16:47:55
2014/11/05 16:47:56
2014/11/05 16:47:57
2014/11/05 16:47:58
2014/11/05 16:47:59
2014/11/05 16:48:00
2014/11/05 16:48:01
2014/11/05 16:48:02

I referred to example sketch on sparkfun.

Dose anyone know how to fix the problem??

Thank you so much for your great help!!

RTC_SPI_for_setup

#include <SPI.h>
//chip select = 8, CLK = 13, MISO = 12, MOSI = 11
const int  cs=8; //chip select 

void setup() {
  Serial.begin(9600);
  RTC_init();
  //day(1-31), month(1-12), year(0-99), hour(0-23), minute(0-59), second(0-59)
  //SetTimeDate(5,11,14,15,51,00);  //setup current time
}

void loop() {
  Serial.println(ReadTimeDate());
  delay(1000);
}
//=====================================
int RTC_init(){ 
  pinMode(cs,OUTPUT); // chip select
  // start the SPI library:
  SPI.begin();
          SPI.setBitOrder(MSBFIRST); 
  SPI.setDataMode(SPI_MODE3); // both mode 1 & 3 should work 
  //set control register 
  digitalWrite(cs, LOW);  
  SPI.transfer(0x8E);
  SPI.transfer(0x60); //60= disable Osciallator and Battery SQ wave @1hz, temp compensation, Alarms disabled
  digitalWrite(cs, HIGH);
  delay(10);
}
//=====================================
int SetTimeDate(int d, int mo, int y, int h, int mi, int s){ 
 int TimeDate [7]={s,mi,h,0,d,mo,y};
 for(int i=0; i<=6;i++){
 if(i==3)
 i++;
 int b= TimeDate[i]/10;
 int a= TimeDate[i]-b*10;
 if(i==2){
 if (b==2)
 b=B00000010;
 else if (b==1)
 b=B00000001;
 } 
 TimeDate[i]= a+(b<<4);
  
 digitalWrite(cs, LOW);
 SPI.transfer(i+0x80); 
 SPI.transfer(TimeDate[i]);        
 digitalWrite(cs, HIGH);
  }
}
//=====================================
String ReadTimeDate(){
 String temp;
        char timechar[30] = "";
 int TimeDate [7]; //second,minute,hour,null,day,month,year 
 for(int i=0; i<=6;i++){
 if(i==3)
 i++;
 digitalWrite(cs, LOW);
 SPI.transfer(i+0x00); 
 unsigned int n = SPI.transfer(0x00);        
 digitalWrite(cs, HIGH);
 int a=n & B00001111;    
 if(i==2){ 
 int b=(n & B00110000)>>4; //24 hour mode
 if(b==B00000010)
 b=20;        
 else if(b==B00000001)
 b=10;
 TimeDate[i]=a+b;
 }
 else if(i==4){
 int b=(n & B00110000)>>4;
 TimeDate[i]=a+b*10;
 }
 else if(i==5){
 int b=(n & B00010000)>>4;
 TimeDate[i]=a+b*10;
 }
 else if(i==6){
 int b=(n & B11110000)>>4;
 TimeDate[i]=a+b*10;
 }
 else{ 
 int b=(n & B01110000)>>4;
 TimeDate[i]=a+b*10; 
 }
 }
        sprintf(timechar, "20%02d/%02d/%02d   %02d:%02d:%02d", TimeDate[6],TimeDate[5],TimeDate[4],TimeDate[2],TimeDate[1],TimeDate[0]);
        //20yy/mm/dd   hh/mm/ss
        //I used "sprintf" for arrange number fo digits
        temp = timechar; 
  return(temp);
}

Please post a picture of your wiring. How do you power your Arduino/the DS3234?

There are a couple of potential problems in ReadTimeDate which are probably combining to cause the wrong date/time.
First, don't use the String class.
Second, ReadTimeDate returns the value of a local variable which can be arbitrarily clobbered.

Remove all references to String, declare timechar to be global, and just print it.

Pete

I understand why it doesn't work. Actually the problem comes from hardware error. The cause of that problem was Arduino board, I guess especially something about SPI communication.

I'm sorry guys... I really appreciate you!!

What hardware error? What was "something about SPI communication"?
Even if there was a hardware error, you still have software problems to fix.

Pete

I'm not sure detail of Arduino circuit and designs.... so I can't specify where is broken or error. However I can specify the cause is something about SPI. Finally, my arduino was just defective product.
I confirmed the hardware SPI error by myself. First, I tried to el_supremo's idea, it still didn't work. And then I changed the Arduino Board and worked well. I also tried SD(read&write) program on broken Arduino, of course the program didn't work. The common factor was only SPI communication.

I'm using el_supremo's idea now, that's no problem.
Thanks all of you!!