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 ?)

Gerald Schneider
  • 19,757
  • 8
  • 52
  • 79
  • 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 08: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 08:17
  • The [documentation of GNU date](https://www.gnu.org/software/coreutils/manual/html_node/Time-conversion-specifiers.html#Time-conversion-specifiers) 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 08:20

0 Answers0