Q:

How can I convert a string into date with different timezone in Linux?

I want to convert a date string in IST timezone format to date in GMT timezone.
Date String:
2017-01-29 08:58:09 IST

Expected Output:
2017-01-29 03:28:09 GMT

Is it possible?

A:

With GNU date:
$ TZ=GMT date -d '2017-01-29 08:58:09 IST' +'%F %T %Z'
2017-01-29 03:28:09 GMT

The -d option specifies which time to print (instead of "now"), the +'%F %T %Z' output format string is short for %Y-%m-%d %H:%M:%S %Z, and TZ=GMT sets the TZ environment variable for the command to GMT.

