INT 21h AH=2Ch returns the time of day in four byte registers, all binary: the hour in CH, the minute in CL, the second in DH and hundredths of a second in DL. DOS does not run a clock of its own for this; it converts the BIOS tick count, the number of timer interrupts since midnight, which goes up 18.2 times a second.

prints the box's time, for example: 14:05:09.34
MOV AH, 2Ch ; DOS: get the time
INT 21h ; CH = hour, CL = minute, DH = second, DL = 1/100 s
PUSH DX
PUSH CX
MOV AL, CH
CALL P2D1 ; the hour
MOV DL, ":"
MOV AH, 02h ; DOS: print the character in DL
INT 21h
POP CX
MOV AL, CL
CALL P2D1 ; the minute
MOV DL, ":"
MOV AH, 02h ; DOS: print the character in DL
INT 21h
POP DX
PUSH DX
MOV AL, DH
CALL P2D1 ; the second
MOV DL, "."
MOV AH, 02h ; DOS: print the character in DL
INT 21h
POP DX
MOV AL, DL
CALL P2D1 ; the hundredths
P2D1 PROC NEAR ; print AL (0-99) as two digits
AAM ; AH = AL / 10, AL = AL mod 10
ADD AX, 3030h ; both digits to characters
PUSH AX
MOV DL, AH ; the tens
MOV AH, 02h
INT 21h
POP DX ; DL = the units
MOV AH, 02h
INT 21h
RET
P2D1 ENDP

The hundredths are not exact to 1/100 s. The tick count changes every 55 ms, so DL moves in steps of 5 or 6, and two calls within one tick return the same time. Still, the second in DH is good enough to wait for, as here:

prints, within a second: a new second has begun
MOV AH, 2Ch ; DOS: get the time
INT 21h
MOV BL, DH ; the current second
WAIT1:
MOV AH, 2Ch
INT 21h
CMP DH, BL
JE WAIT1 ; until the next second begins
MOV DX, OFFSET MSG1
MOV AH, 09h ; DOS: print the string at DS:DX
INT 21h
MSG1 DB "a new second has begun", 13, 10, "$"

To time something, read the time before and after, turn both into hundredths since midnight (((hours × 60 + minutes) × 60 + seconds) × 100 + hundredths, which needs 32 bits) and subtract. For intervals of less than a tick the BIOS tick count is no help either; the timer chip itself has to be read.

Pitfalls

At midnight the time wraps to 00:00:00.00 and the difference of two readings turns negative: add 24 hours when it does. The BIOS signals midnight with a flag DOS uses to advance its date, so read the time through DOS rather than with INT 1Ah AH=00h when the date matters. The real-time clock of an AT (INT 1Ah AH=02h) is a separate clock, in BCD, which DOS reads only at boot. DOSBox-X spends a little emulated time in each call on purpose: some games measure their speed by calling it in a loop.