Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get current Unix time in nanoseconds in Android Shell?

I need to get timestamps in nanoseconds in Android shell. Using date command (from busybox and Cyanogenmod) returns to me this:

@A001 # date +%s.%N
1819.N

The only other working option that I found is using www.timeapi.org.

curl -sSw'\n' http://www.timeapi.org/utc/now?\\s.\\N >> ctime_tar.txt

However, it requires connection and also takes 0.1 seconds to execute.

What can I use? I really need to get time in nanoseconds, especially something I can execute as a single command.

like image 613
22332112 Avatar asked Nov 27 '25 23:11

22332112


1 Answers

You could try to use EPOCHREALTIME environment variable:

$ adb shell echo \$EPOCHREALTIME
1430637292.923135
like image 123
Mattia Maestrini Avatar answered Nov 30 '25 12:11

Mattia Maestrini



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!