Page 1 of 1

Date in Bash

Posted: Tue Dec 08, 2015 8:17 pm
by expandables
I'm writing a Time script in bash but when I execute the script I don't get the current time :(

Code: Select all

CURRENT_TIME=$(date + "%x %r %Z")
:twisted:

Re: Date in Bash

Posted: Tue Dec 08, 2015 8:28 pm
by joan
Perhaps the space after the +.

Re: Date in Bash

Posted: Tue Dec 08, 2015 8:45 pm
by expandables
joan wrote:Perhaps the space after the +.
Thanks it now works :D
:twisted:

Re: Date in Bash

Posted: Sat Dec 12, 2015 3:11 am
by swampdog
Never mess with time.

Code: Select all

$ date "+%x %r %Z"
.. is likely what you wanted. Always log UTC (aka GMT time). A good format is..

YYYY-MM-DD-hh:mm:ss:[nano secs or whatever]

..because it is both language and timezone agnostic.