for date write into the SD card problem

right now, I stuck on this problem. I need to code to write the data and date into the SD card, but the date shows on the monitor, not show in the SD card. can you tell me how to code it can let every data with time write in the SD card? thank you
here is my code
#include <RTClib.h>
#include <SD.h>
#include <SPI.h>
#include <Wire.h>
#include “MS5837.h”
#include “Wire.h”
#define DS3231_I2C_ADDRESS 0x68
// Convert normal decimal numbers to binary coded decimal
byte decToBcd(byte val){
return( (val/1016) + (val%10) );
}
// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val){
return( (val/16
10) + (val%16) );
}

const int cs=10;
const int MOSIpin=11;
const int MISOpin=12;
MS5837 sensor;
File sensorFile;

void setup() {

Serial.begin(9600);

Serial.println(“Starting”);

Wire.begin();
Serial.print(“Initializing card…”);
// make sure that the default chip select pin is declared OUTPUT

pinMode(10, OUTPUT);

// see if the card is present
if (!SD.begin(cs))
{
Serial.println(“Card failed to initialize, or not present”);

return;
}
Serial.println(“card initialized.”);

// open the file named Hellofile.txt

File sensorFile = SD.open(“Hello.txt”);

// if the file is available, read the file
if (sensorFile)
{
while (sensorFile.available())
{
Serial.write(sensorFile.read());
}
sensorFile.close();
}
// if the file cannot be opened give error report
else {
Serial.println(“error opening the text file”);
}

sensor.setModel(MS5837::MS5837_02BA);
sensor.init();

sensor.setFluidDensity(997); // kg/m^3 (997 freshwater, 1029 for seawater)

// set the initial time here:
// DS3231 seconds, minutes, hours, day, date, month, year
setDS3231time(30,42,16,5,13,10,16);
}
void setDS3231time(byte second, byte minute, byte hour, byte dayOfWeek, byte
dayOfMonth, byte month, byte year){
// sets time and date data to DS3231
Wire.beginTransmission(DS3231_I2C_ADDRESS);
Wire.write(0); // set next input to start at the seconds register
Wire.write(decToBcd(second)); // set seconds
Wire.write(decToBcd(minute)); // set minutes
Wire.write(decToBcd(hour)); // set hours
Wire.write(decToBcd(dayOfWeek)); // set day of week (1=Sunday, 7=Saturday)
Wire.write(decToBcd(dayOfMonth)); // set date (1 to 31)
Wire.write(decToBcd(month)); // set month
Wire.write(decToBcd(year)); // set year (0 to 99)
Wire.endTransmission();
}
void readDS3231time(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year){
Wire.beginTransmission(DS3231_I2C_ADDRESS);
Wire.write(0); // set DS3231 register pointer to 00h
Wire.endTransmission();
Wire.requestFrom(DS3231_I2C_ADDRESS, 7);
// request seven bytes of data from DS3231 starting from register 00h
*second = bcdToDec(Wire.read() & 0x7f);
*minute = bcdToDec(Wire.read());
*hour = bcdToDec(Wire.read() & 0x3f);
*dayOfWeek = bcdToDec(Wire.read());
*dayOfMonth = bcdToDec(Wire.read());
*month = bcdToDec(Wire.read());
*year = bcdToDec(Wire.read());
}
void displayTime(){
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
// retrieve data from DS3231
readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month,
&year);
// send it to the serial monitor
Serial.print(hour, DEC);
// convert the byte variable to a decimal number when displayed
Serial.print(":");
if (minute<10){
Serial.print(“0”);
}
Serial.print(minute, DEC);
Serial.print(":");
if (second<10){
Serial.print(“0”);
}
Serial.print(second, DEC);
Serial.print(" “);
Serial.print(dayOfMonth, DEC);
Serial.print(”/");
Serial.print(month, DEC);
Serial.print("/");
Serial.print(year, DEC);
Serial.print(" Day of week: ");
switch(dayOfWeek){
case 1:
Serial.println(“Sunday”);
break;
case 2:
Serial.println(“Monday”);
break;
case 3:
Serial.println(“Tuesday”);
break;
case 4:
Serial.println(“Wednesday”);
break;
case 5:
Serial.println(“Thursday”);
break;
case 6:
Serial.println(“Friday”);
break;
case 7:
Serial.println(“Saturday”);
break;
}

}
void loop() {

sensor.read();

Serial.print(“Pressure: “);
Serial.print(sensor.pressure());
Serial.println(” mbar”);

Serial.print(“Temperature: “);
Serial.print(sensor.temperature());
Serial.println(” deg C”);

Serial.print(“Depth: “);
Serial.print(sensor.depth());
Serial.println(” m”);

Serial.print(“Altitude: “);
Serial.print(sensor.altitude());
Serial.println(” m above mean sea level”);

sensorFile = SD.open(“Hello.txt”,FILE_WRITE);
sensorFile.print(“Pressure: “);
sensorFile.print(sensor.pressure());
sensorFile.println(” mbar”);

sensorFile.print(“Temperature: “);
sensorFile.print(sensor.temperature());
sensorFile.println(” deg C”);

sensorFile.print(“Depth: “);
sensorFile.print(sensor.depth());
sensorFile.println(” m”);

sensorFile.print(“Altitude: “);
sensorFile.print(sensor.altitude());
sensorFile.println(” m above mean sea level”);

Serial.print("Time: ");

Serial.println(" Date");
sensorFile.close();
displayTime(); // display the real-time clock data on the Serial Monitor,
delay(1000); // every second

}

In the displayTime() function write to SD instead of Serial. CAll the function when you need to write the date/time