Nijin Narayanan Nijin Narayanan - 4 months ago 33
Bash Question

Cygwin return different format of date for `date -u` command

When I execute

date -u
command from Cygwin Terminal / Cygwin Bash shell, It returns the output
Tue, Jul 14, 2015 2:52:47 PM

But when i executed
command from command line, then executed
date -u
, it returns the output
Tue Jul 14 14:52:27 UTC 2015

I need this command to be always return this output format:
Tue Jul 14 14:52:27 UTC 2015 (%a %b %d %H:%M%S %Z %Y)

Why it return different datetime format? How can I change these to same format?

Path for different Cygwin terminal:

Cygwin Terminal: C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico -
Cygwin Bash shell: C:\cygwin\Cygwin.bat
Bash: C:\cygwin\bin\bash.exe


The date format depends on the system's locale:

$ LC_ALL=it_IT.utf8 date -u
mar 14 lug 2015, 18.04.18, UTC

$ LC_ALL=POSIX date -u
Tue Jul 14 18:04:29 UTC 2015

If you want consistent date output, explicitly set your system, user, script or date command to use the POSIX locale.