When I run date +"%Y%m%d%H%M%S"
I receive 20171225203309
here in CET time zone.
Can I use date
to obtain a the current time in the same format, but for timezone GMT?
You can use date -u
(universal time) which is equivalent to GMT.
Quoting date
manual:
‘-u’ ‘--utc’ ‘--universal’
Use Universal Time by operating as if the ‘TZ’ environment variable were set to the string ‘UTC0’. UTC stands for Coordinated Universal Time, established in 1960. Universal Time is often called “Greenwich Mean Time” (GMT) for historical reasons. Typically, systems ignore leap seconds and thus implement an approximation to UTC rather than true UTC.
Use the following command:
TZ=GMT date
The same format:
TZ=GMT date +"%Y%m%d%H%M%S"
20171225194014
date -u
only mentioned (as answer) here.TZ
environment variable. OP of that question even mentions this: "Looking through man date I see that I can have the time output as UTC"