try
String filename;
void setup() {}
void draw() {}
void keyPressed() { //variables used for the filename timestamp
//variable as string under the data folder set as data/yyyy-mm-dd--hh-min-sec_millis.csv
filename = "data/" + year()+"-"+ nf(month(),2,0) +"-"+ nf(day(),2,0)+"--"+ nf(hour(),2,0) +"-"+ nf(minute(),2,0) +"-" + nf(second(),2,0) +"_"+millis() + ".csv";
// please note that millis() is the milli seconds since start of sketch!
println(filename);
}
https://processing.org/reference/millis_.html
https://processing.org/reference/nf_.html
shows like
data/2019-07-25--09-18-50_9401.csv
data/2019-07-25--09-18-51_10340.csv
data/2019-07-25--09-18-52_11138.csv