Skip to content

Get timezone automatically #7

@tukusejssirs

Description

@tukusejssirs

You could add automatic retrival of timezone base on IP location. I use jq to parse the JSON, but you could use grep -Po '"timezone": "\K[^"]*' <<< "$IP_INFO", too.

setTimeZone(){
	# Get location-based timezone
	IP_INFO="$(curl -s https://ipinfo.io)"
	IP_TZ="$(jq -r .timezone 2>/dev/null <<< "$IP_INFO")"

	# Set time zone
	read -p "Enter the time zone [$IP_TZ]: " time_zone

	if [ ! "$timezone" ]; then
		time_zone="$IP_TZ"
	fi
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions