I have a string '2015_11_01_00_00' I want this convert into epoch time. I have tried the below code, but could not found it worth.
#!/bin/bash echo "mohit" date_var="2015_11_01_00_00" echo $date_var arr=$(echo $date_var | tr "_" "\n") IFS='_ ' read -r -a arr <<< "$date_var" #echo $arr echo ${arr[0]} echo ${arr[1]} echo ${arr[2]} echo ${arr[3]} echo ${arr[4]} updated_date="${arr[0]}"-"${arr[1]}"-"${arr[2]}"-"${arr[3]}"-"${arr[4]}" echo $updated_date TMRW_DATE=`date --date="$updated_date" +"%s"` echo "$TMRW_DATE"
1459154813can only mean one thing whereas2015_11_01_00_00is ambiguous without a time zone.