Posts Bash format date append static time
Post
Cancel

Bash format date append static time

Linux command to print current date and time

1
$ date

Parameters to get output from date in a custom format

1
$ date +'%m/%d/%Y'

To

  • append static time to the date
  • save it to a variable
  • echo the date time
1
2
3
$ NOW="$(date +'%m/%d/%Y') 20:00:00"

$ echo $NOW

For more examples visit stackoverflow concatenate string variables in Bash

This post is licensed under CC BY 4.0 by the author.