Code to convert CDT to EDT

Input=$(awk -F="," '/pattern/ {print $1}' logfile | tail -1)
Input=2016-06-08 23:45:36

I have a log file from where I get above CDT time 'Input', want to convert it to below format EDT time

Required output: 8/6/16 11:45 PM

#I want to get "23:45:36" in below HMS variable but it has issue

HMS=$(awk -v val=$Input '{print $2,val})

CT=`date +%Z`

if [ $CT -eq "EST" ]; then   

#if EST then it is same CST time, so just formate change
    F2=$(date +%r --date="$HMS" |cut -c 1-5,9-11)

    F1=$(awk -F"-" -v val1=Input '{print $3"/"$2"/"$1,val1}')
    echo $F1 $F2> $ET
else 
#if CDT then one hour to be added to match EDT time 

    F1=$(awk -F"-" -v val1=Input '{print $3"/"$2"/"$1,val1}')
    F2=$(date +%r --date="$HMS" "+1 hour" | cut -c 1-5,9-11)
 
    echo $F1 $F2 >$ET
fi

The time increment and formatting not working properly, need help to get the output: 8/6/16 11:45 PM.

It's difficult to tell if your date version allows for the -d, --date= argument or not. If it does, try

LC_ALL=C date -d"$Input" +"%-m/%-d/%y %I:%M %p"
6/8/16 11:45 PM

For your HMS problem, try

HMS=${Input#* }

I am using bash

When we get CDT time from log, the time difference to EDT will be one hour. During that time increment, can we do the below?

CL_ALL=C date -d"$Input" +"%-m/%-d/%y %I:%M %p" "+1 hour" 

First, why did you change LC_ALL in RudiC's suggestion to

CL_ALL

?

Second, why did you change:

+"%-m/%-d/%y %I:%M %p"

to:

+"%-m/%-d/%y/ %I:%M %p"

? Do you really want to print a <slash> character after the year in your output?

Third, telling us that you use bash does not tell us whether or not the date utility on your operating system supports a -d option that will behave this way. The date -d option on my system does not behave this way on the system I'm using so I can't verify this, but I would think you want something more like:

LC_ALL=C date -d"$Input +1 hour" '+%-m/%-d/%y %I:%M %p'

Fourth, the test operator for string comparison is = , not -eq (which is for numeric comparisons) and, even if it did work, your test would only work when daylight saving time is not in effect. Maybe:

if [ $CT -eq "EST" ]; then

would come closer to doing what you want if you used:

if [ "$CT" = "EST" ] || [ "$CT" = "EDT" ]; then

unless you live in some parts of Indiana.

Thanks RudiC and Don.... Solution worked... Also I had another time conversation to take care in this below formate

CT="Wed Jun 22 22:20:45 CDT 2016
                                                                                      And used this code and it converted to my system EDT time, with addition of 1hour                       
 date --date="$CT" +"%-m/%-d/%y %I:%M %p"
                       Just want to know above code is fine in all 365 days or any other better way to handle this?