I am trying to get a bash script working and in order to do so I need to transform a local time in +%Y%m%d%H%M%S
format (example: "20150903170731") into UTC time in the same format.
I know date -u
can give me the current UTC time:
$ date +%Y%m%d%H%M%S -u
20150903161322
Or, without the -u
the local time (here, BST):
$ date +%Y%m%d%H%M%S
20150903171322
Now if I add an argument to date
, I get an error:
echo "20150903154607" | xargs date +"%Y%m%d%H%M%S" -u
date: extra operand `20150903154607'
Is there any way I can do perform this conversion without such errors?