As I already wrote, use the millis() call to get the number of milliseconds since startup. Store that value an compare the current value to the stored one to get the milliseconds since then. To make that run as you want it, remove all the delay() calls from your sketch.