0
MYENV=$(date +"%s%N")
printf "Time:: %s\n" "$MYENV"

or

MYENV1=$(date +"%T%N")
printf "Time:: %s\n" "$MYENV1"

I tried above methods, they do work in regular linux but not working in buildroot.

1606718041%N is the output being printed. What does this mean? Is this a specific format? How to decode this? (If I'm not wrong this is the time since epoch, correct ?)

3
  • If %T is working and %N isn't my guess would be that the version of date in your build environment is a version that doesn't support that sequence. – Gerald Schneider Nov 30 '20 at 8:15
  • try running \date, or run it with an absolute path to make sure you run the same binary from your manual run and not an alias or a replacement. – Gerald Schneider Nov 30 '20 at 8:17
  • The documentation of GNU date states that %N is a GNU extension, so it's not surprising if it doesn't exist in other implementations of date – Gerald Schneider Nov 30 '20 at 8:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.