29 nov 2025
- BASH
- CLAUDE.AI
I want to conver my time in CST timezone with bash script
I can help you create a bash script to convert times to CST timezone. Here’s a simple and effective script:
#!/bin/bash
# Get current time in CST (Central Standard Time)
# CST is UTC-6, but we'll use America/Chicago which handles CST/CDT automatically
# Display current time in CST
echo "Current time in CST/CDT:"
TZ='America/Chicago' date
# Or if you want to convert a specific time
echo -e "\nTo convert a specific time, use:"
echo "TZ='America/Chicago' date -d 'your_time_here'"
# Example: Convert current UTC time to CST
echo -e "\nCurrent UTC time:"
TZ='UTC' date
echo -e "Same time in CST/CDT:"
TZ='America/Chicago' date
If you want a more interactive script that converts specific times:
#!/bin/bash
# Interactive time converter to CST
if [ $# -eq 0 ]; then
# No arguments - show current time in CST
echo "Current time in CST/CDT: $(TZ='America/Chicago' date)"
else
# Convert provided time to CST
echo "Converting: $*"
TZ='America/Chicago' date -d "$*"
fi
Usage examples:
# Make it executable
chmod +x time_to_cst.sh
# Show current CST time
./time_to_cst.sh
# Convert specific times
./time_to_cst.sh "2024-03-15 14:30:00 UTC"
./time_to_cst.sh "now"
./time_to_cst.sh "tomorrow 10:00"
Note: The script uses America/Chicago timezone which automatically handles:
- CST (Central Standard Time) = UTC-6 (winter)
- CDT (Central Daylight Time) = UTC-5 (summer)
Would you like me to customize this script for a specific use case, such as converting times from a particular timezone or formatting the output differently?