Save exact time in a variable, when sensor is activated

I am trying to save the exact time in a variable ,when the sensor is activated.( Every time it detects a button push).

#include <UTFTGLUE.h>
#include <Adafruit_GFX.h> // Core graphics library
#include <MCUFRIEND_kbv.h> // Hardware-specific library
MCUFRIEND_kbv tft;
#include <Time.h>
#include <Button.h>

#include <Fonts/FreeSans9pt7b.h>
#include <Fonts/FreeSans12pt7b.h>
#include <Fonts/FreeSerif12pt7b.h>

#include <FreeDefaultFonts.h>

#define BLACK 0x0000
#define RED 0xF800
#define GREEN 0x07E0
#define WHITE 0xFFFF
#define GREY 0x8410

#define Time_REQUEST 7

int counter;

UTFTGLUE myGLCD(0,A2,A1,A3,A4,A0);

int fsrPin = A12; // the FSR and 10K pulldown are connected to a0
int fsrReading; // the analog reading from the FSR resistor divider
int fsrVoltage; // the analog reading converted to voltage
int count=0;

unsigned long fsrResistance; // The voltage converted to resistance, can be very big so make “long”
unsigned long fsrConductance;

long fsrForce; // Finally, the resistance converted to force

byte hh=0; byte mi=0; byte ss=0; // hours, minutes, seconds
unsigned int dddd=0; // days (for if you want a calendar)
unsigned long lastTick=0; // time that the clock last “ticked”
char timestring[17]; // for output
int tiempodecontraccion;

const int buttonPin = A12; // the pin that the pushbutton is attached to

// Variables will change:
int buttonPushCounter = 0; // counter for the number of button presses
int buttonState = 0; // current state of the button
int lastButtonState = 0;

void setup(void) {
// Setup the LCD

myGLCD.InitLCD();
Serial.begin(9600);
pinMode(fsrReading, INPUT);
pinMode(buttonPin, INPUT);

uint16_t ID = tft.readID();

if (ID == 0xD3) ID = 0x9481;
tft.begin(ID);
tft.setRotation(1);
tft.fillScreen(BLACK);

myGLCD.clrScr();
myGLCD.setColor(255, 255, 255);
myGLCD.fillRect(0, 0, 479, 13);
myGLCD.setColor(255, 0, 0);
myGLCD.fillRect(0, 306, 479, 319);
myGLCD.setColor(255, 255, 255);
//myGLCD.setBackColor(255, 255, 255);
showmsgXY(40, 175, 2, &FreeBigFont, “Fetal Monitor”);
showmsgXY(330, 320, 1, &FreeSmallFont, “by: Jose & Andrea”);
myGLCD.setBackColor(255, 255, 255);
myGLCD.setColor(255, 255, 255);
delay(2000);
myGLCD.clrScr();
}

////////////////////////////////UTFT SETTING/////////////////////////////////////
void showmsgXY(int x, int y, int sz, const GFXfont *f, const char *msg)
{
int16_t x1, y1;
uint16_t wid, ht;
//tft.drawFastHLine(0, y, tft.width(), WHITE);
tft.setFont(f);
tft.setCursor(x, y);
tft.setTextColor(WHITE);
tft.setTextSize(sz);
tft.print(msg);
//delay(1000);
}

void loop(void) {

buttonState = digitalRead(buttonPin);

// compare the buttonState to its previous state
if (buttonState != lastButtonState) {
// if the state has changed, increment the counter
if (buttonState == HIGH) {
// if the current state is HIGH then the button went from off to on:
buttonPushCounter++;
Serial.println(“on”);
Serial.print("number of button pushes: ");
Serial.println(buttonPushCounter);

} else {
// if the current state is LOW then the button went from on to off:
Serial.println(“off”);
}
// Delay a little bit to avoid bouncing
delay(50);
}
// save the current state as the last state, for next time through the loop
lastButtonState = buttonState;

/////////////////////////Sensor fsr///////////////////////////////////

fsrReading = analogRead(fsrPin);
Serial.print("Analog reading = ");
Serial.println(fsrReading);

// analog voltage reading ranges from about 0 to 1023 which maps to 0V to 5V (= 5000mV)
fsrVoltage = map(fsrReading, 0, 1023, 0, 5000);
Serial.print("Voltage reading in mV = ");
Serial.println(fsrVoltage);

if (fsrVoltage == 0) {
Serial.println(“No pressure”);
Serial.println("--------------------");
count= 0;
myGLCD.clrScr();
showmsgXY(40, 175, 2, &FreeBigFont, "No Pressure ");

delay(500);

}

else {
//The voltage = Vcc * R / (R + FSR) where R = 10K and Vcc = 5V
// so FSR = ((Vcc - V) * R) / V
fsrResistance = 5000 - fsrVoltage; // fsrVoltage is in millivolts so 5V = 5000mV
fsrResistance *= 10000; // 10K resistor
fsrResistance /= fsrVoltage;
Serial.print("FSR resistance in ohms = ");
Serial.println(fsrResistance);

}

if(fsrReading != 0){
count++;
myGLCD.clrScr();
showmsgXY(40, 175,2, &FreeSmallFont, “Contraction Time:”);
myGLCD.printNumI(count,CENTER,190);

Serial.print (“Contraction time= “);
Serial.println(count, DEC);
Serial.println(”--------------------”);
delay(1000);
}

// this part goes in your “loop”
if ((micros() - lastTick) >= 1000000UL) {
lastTick += 1000000UL;
ss++;
if (ss>=60) { ss-=60; mi++; }
if (mi>=60) { mi-=60; hh++; }
if (hh>=24) { hh-=24; dddd++; }
}

// To display the time in the serial monitor:
sprintf(timestring,"%02d:%02d:%02d", hh, mi, ss);
Serial.println(timestring);

}

What is your problem?
Please put your code inside code tag!

I took at a glance at your code, there are two issues you SHOULD fixed.

  1. Use pull-up or pull-down for button
  2. DO NOT use delay(), in timestamp instead, See BlinkWithoutDelay example