FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

14455 questions

17168 answers

28195 comments

0 members

We are migrating to our new platform at https://community.teltonika.lt. Moving forward, you can continue discussions on this new platform. This current platform will be temporarily maintained for reference purposes.
0 votes
69 views 1 comments
by anonymous

I'm trying to use date -D "%Y %m %d %H %M %S" to emit simple easily parsed date data

I observe that no matter what I put after -D 
the result is always the same bog-standard  format :  Tue Feb 21 19:38:41 MST 2023

if I put nothing after -D I get the Usage stuff

1 Answer

+1 vote
by anonymous

Hello,

You can try the following couple of options:

  • date +"%Y %m %d %H %M %S"
  • date +"Year: %Y Month: %m Day: %d Hour: %H Minute: %M Second: %S"
  • date +"DATE: %D TIME: %T"

The basic idea is to use "+" sign to format date command's output.

Best regards,

by anonymous

Thank you!

DOH!!
I now see that the formatting of date -h is confusing and I failed to see a crucial detail: +FMT
I went directly to looking at the OPTIONS

Usage: date [OPTIONS] [+FMT] [[-s] TIME]

Display time (using +FMT), or set time