Error geting RTC

Hi! I am trying to make a project using an Arduino and WiFly Shield. The main propose of this program is to get from the Wifly Shield an RTC(after it’s synchronize with a NTP server) and send it to a client server via WiFi. The problem is that i get to the server and other stuffs like:

1412168529
1412168531
1412168533
$$$
ver
1412168536
1412168538

I really don`t know why I get this. Also my code is this :

#include <SPI.h>
#include "WiFly.h"

char passphrase[] = "**********";
char ssid[] = "*********";
WiFlyClient client("*************",5500);


bool checkNetwork()
{
  const char * status=WiFly.getConnectionStatus();
  if(status[1]=='3')
  {
    return true;
  }
  else
  {
    return false;
  }
  
}


void setup() 
{
  //Serial.begin(9600); // Establish Serial connection for output
  WiFly.begin();
  if(!checkNetwork())
    { 
      //Serial.println("Not connected to the wifi network.");
      while(!WiFly.join(ssid,passphrase))
      {
        //Serial.println("Joining the network failed. Retrying....");
               
      }
      //Serial.println("Joined!");
    }
  delay(7000);
}

void loop() {
  long RTC;
  RTC=grabTime(); // Set the system clock to match the WiFly RTC
  if(client.connect())
  {
    client.println(RTC);
    client.flush();
    client.stop();
  } 
}

long grabTime(void)
{
 SpiSerial.begin(); 
 delay(250); // The delay buffer before and after were pulled from the WiFly library itself
 SpiSerial.print("$$");
 delay(250); // The delay buffer before and after were pulled from the WiFly library itself
 SpiSerial.println("\n"); // The WiFly library also recommended two carraige returns to clear things up
 Flush_RX(); // I added this last bit to clear out the receive buffer in preparation for pulling the time
 // Without this Flush_RX() here, potentially the first couple results returned would not be accurate

 SpiSerial.println("show t t"); // Request the current RTC value from the WiFly card
 int linesSoFar=0; // Variable to track the line number in the output we receive
 int afterEquals=0; // Flag to trigger after equals sign -- when the RTC value begins
 char timestr[12]=""; // Variable to store the UNIX timestamp from the RTC clock
 int charNumber=0; // Counter to store the position number inside the UNIX timestamp char above

 // This for loop runs with a total delay of 100ms to ensure that the results of the command have been received
 // before allowing the program to loop and accept more input. Without this forced acceptance of incoming data,
 // unexpected results can be seen.
 for(int z=0;z<=100;z++) 
   {     
    // Loop while there is incoming data from the WiFly module(in response to our show t t command above)
    while(SpiSerial.available() > 0) 
      {
       char c = SpiSerial.read(); // Read in one character
       if(c=='\n') linesSoFar++; // If the character read in is a line feed, then add one to the counter for number of lines

       // Potential lines might look like: RTC=1331449728
       if(linesSoFar==3) // The third line in the results contains the RTC value
         {
          if(afterEquals==1) // Only perform the code below if our character position on the RTC line is after the =
            { timestr[charNumber] = (char)c; charNumber++; } // Store the character into our character array
          if(c=='=') afterEquals=1; // If the current character is an equals, the next character begins our RTC value -- throw flag
         }
      }
    delay(1); // Delay for 1ms
   }
   long returnL = strToLong(timestr); // Convert our character aray into a long
    SpiSerial.println("");
    SpiSerial.println("exit");
   return(returnL);
}

// I found this command to be needed so that the receive buffers are flushed
// This helps normalize output so that the time grabbing works consistently
void Flush_RX()
{
 for(int z=0;z<=100;z++) 
   {     
    // Loop while there is incoming data from the WiFly module(in response to our show t t command above)
    while(SpiSerial.available() > 0) 
       char c = SpiSerial.read(); // Read in one character
    delay(1);
   }
 return;
}

// Pulled from: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1286545227
long strToLong(String s) { char arr[12]; s.toCharArray(arr, sizeof(arr)); return atol(arr); }

Could anyone give me some advices. Thanks!

moderator: added code tags ==> # button above smileys Please use them

Check - http://www.epochconverter.com/epoch/clock.php -

The numbers you get are the number of seconds since 1-1-1970 or 1-1-2000 can you check if it increments one per second?

if so, there is some code - http://playground.arduino.cc/Main/DS1307OfTheLogshieldByMeansOfNTP - to do conversion to year month day hour minute seconds.

I know that . That is the UNIX time (more exactly from 1970 ). The main problem is that i get : "$$$ ver". I don`t understand why the Arduino is sending this kind of data. I only need the RTC ,because after this, I will make the convertion (year, month, day , etc) on a computer , from the server. Thanks!

The main problem is that i get : “$$$ ver”. I don`t understand why the Arduino is sending this kind of data.

it is in your code - **SpiSerial.print("$$$"); ** - so why did you put it in?

that`s in the SpiSerial , not to the client serial. all i got on my server is from client.print() form. also from where i get the "$$$"?