Display local time as YYYY-MM-DD HH:MM:SS.
Which command is appropriate?
date +FORMAT accepts %F for the date and %T for time with seconds.
Detailed explanation
date '+%F %T'Correct. %F expands to the date and %T to the time with seconds.
Correct. %F expands to the date and %T to the time with seconds.
date '+%Z %z'Incorrect. %Z and %z display timezone information.
Incorrect. %Z and %z display timezone information.
date '+%s'Incorrect. %s displays epoch seconds.
Incorrect. %s displays epoch seconds.
hwclock --showIncorrect. hwclock reads the RTC rather than formatting date output as requested.
Incorrect. hwclock reads the RTC rather than formatting date output as requested.
Try it yourself
An example you can run in a temporary verification environment.
date '+%F %T'Expected result
実行時点のYYYY-MM-DD HH:MM:SSKey points
- +FORMAT
- %F is date
- %T is time
Notes
- Environment: GNU date / 読取のみ
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.