Last active
January 19, 2021 22:13
-
-
Save dominique-mueller/f823e2eb6972c741598843e4641143d9 to your computer and use it in GitHub Desktop.
Switch timezone on linux systems. Very helpful when running tests on a CI and verifying that timezone logic works properly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Switch the timezone on a linux system | |
# | |
# I use this to run unit tests on the CI for multiple times with different timezones (at least 2) | |
# Tested on a node alpine docker container on GitLab CI | |
# Timezone values: "UTC", "Europe/Berlin", ... | |
# Fetch timezone data | |
- apk add tzdata | |
# Log out number of timeszones (debug) | |
- ls -1 /usr/share/zoneinfo/ | wc -l | |
# Copy desired timezone to system | |
- cp /usr/share/zoneinfo/UTC /etc/localtime | |
# Set desired timezone | |
- echo "UTC" > /etc/timezone | |
# Log current date in defined timezone (debug) | |
- date |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment