mksh (the standard Android shell since version 4.0) has a built-in EPOCHREALTIME environment variable:
Time elapsed since epoch returned by gettimeofday(2) , formatted as decimal tv_sec followed by a period . and tv_usec, filled with exactly six decimal places.
Thus, the command for obtaining epoch time accurate to the microsecond in Windows will be:
adb shell echo $EPOCHREALTIME
or on Linux:
adb shell 'echo $EPOCHREALTIME'
If you only need millisecond precision:
adb shell 'echo ${EPOCHREALTIME:0:14}'
Or just a part in milliseconds to use with another temporary format:
adb shell 'echo $(date +%T)${EPOCHREALTIME:10:4}'
Alex P.
source share