Noob here, i need help show time and save in .txt file data from giro itg3200

Hi this is my code :

#include <Wire.h>
#include <ITG3200.h>

ITG3200 gyro = ITG3200();
float  x,y,z;
int ix, iy, iz;

void setup(void) {
  Serial.begin(9600);
  Wire.begin();      
  delay(1000);
  
  gyro.init(ITG3200_ADDR_AD0_HIGH); 
  
  Serial.print("zeroCalibrating...");
  gyro.zeroCalibrate(2500, 2);
  Serial.println("done.");
}

void loop(void) {
    while (gyro.isRawDataReady()) {
   
    gyro.readGyro(&x,&y,&z); 
    Serial.print("X3:"); 
    Serial.print(x); 
    Serial.print("  Y:"); 
    Serial.print(y); 
    Serial.print("  Z:"); 
    Serial.println(z);
  } 
}

I use this code to read data from a giro itg 3200 and i need to help me to save the data in file .txt and to show me the time. Please help I’m involved in a school project and whitout this I can’t go on.

Do you have an SD card or some other external media? You could write the data to the EEPROM, but that is much more work…you could write to the SD card with a bit of code I developed a while back:

#include <SD.h>
int value = 0;
int chipSel = 4;
int pin = 0;
void setup() {
  SD.begin(chipSel);//turns on the SD card
}

void loop() {
  value = analogRead(pin);
  File dataFile = SD.open("NAMEOFFILE.txt", FILE_WRITE);
  if (dataFile) {
    dataFile.println(value);
    dataFile.close();
  }
  delay(10000);
}

This file reads data from a pin and writes it to a file every 10 seconds, you should customize it to you needs.
I suggest getting an SD card shield, its easier and you don’t need to be tethered to a computer. If you mean to use Processing on the computer to write it there, I can’t help you, but there are TONS of sites that can help…google!
Karma me if this was helpful!

Download Realterm, use that to capture the Arduino serial port output and output it to a file with timestamps added. There are several options for different formats for the timestamps and I'm sure you'll find one that does what you need.