timestamp for PIR sensor

noob here.
Am trying to get this code to work and wondered if there was a way to add a timestamp to the detected movement.
--thanks

/*

  • PIR sensor tester
    */

int ledPin = 13; // choose the pin for the LED
int inputPin = 2; // choose the input pin (for PIR sensor)
int pirState = LOW; // we start, assuming no motion detected
int val = 0; // variable for reading the pin status

void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inputPin, INPUT); // declare sensor as input

Serial.begin(9600);
}

void loop(){
val = digitalRead(inputPin); // read input value
if (val == HIGH) { // check if the input is HIGH
digitalWrite(ledPin, HIGH); // turn LED ON
if (pirState == LOW) {
// we have just turned on
Serial.println("Motion detected!");
// We only want to print on the output change, not state
pirState = HIGH;
}
} else {
digitalWrite(ledPin, LOW); // turn LED OFF
if (pirState == HIGH){
// we have just turned of
Serial.println("Motion ended!");
// We only want to print on the output change, not state
pirState = LOW;
}
}
}

You can set a variabe equal to millis()
declare it as unsigned long
unsigned long now;
now=millis()

You can convert millis into seconds or hours
if (now - then >= 1000){
seconds ++;
then=now;
}
Or you can divide now by 1000 afterwards

Much Appreciated!

Add a little external hardware, and you can have human friendly date-time information.

There are other answers out there, but I KNOW that the nuelectronics shield... keep reading... would give it to you. Costs less than $20, and offers a lot more, if you want to go farther later.

I said "shield". Don't let that put you off. If you don't want to plug it in as a shield, for the date/time function, you can interconnect your Arduino and the shield with just a few wires.

Details....