On Thu, 1 Jun 2017, Nicolas George wrote:
Le tridi 13 prairial, an CCXXV, SUZANNE COBB a écrit :
I try to capture the date and time into a variable named 'dt':
dt= $(date '+%d/%m/%Y %H:%M:%S');
Note that %T is shorthand for %H:%M:%S
[please see there is a space between = and $, and between Y and %]
Well, fix it! This line executes the output of date as a command with
the dt environment variable set to an empty string. Variable
affectations do not have spaces around the equal.
Also, for scripting, you will want %Y-%m-%d, because it offers a lexical
order.
If you go this convenient-lexical-order route, note that %F is
shorthand for %Y-%m-%d
And for maximum reliability, include the timezone or set it to
UTC.
With timezone:
date +'%F %T %z'
Or simply translated to utc:
date -u +'%F %T'
That's all I got. Good luck with your project.