3

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?

Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
VSP
  • 293
  • 2
  • 5
  • 10

1 Answers1

4

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.

Benjamin W.
  • 46,058
  • 19
  • 106
  • 116