How to convert a date string to the current time zone on the command line?

Solution 1:

Use date -jf "<input format>" "<input value>" +"<output format>".

The following converts a UTC date to my local time zone (CET):

$ date -jf "%Y-%m-%d %H:%M:%S %z" "2011-11-13 08:11:02 +0000" +"%Y_%m_%d__%H_%M_%S"
2011_11_13__09_11_02

If you specify the same date format for both input and output, you will only convert the time to your local time zone. But, as in the example, you can combine that with a format conversion.