differences between hwclock <-> date due to time zone issues? ...
I am using this (yes, visually cr@ppy ;-)) code snippet to set back
the time 5 hours. hwclock tells me it worked fine but the terminal
windows opened before and after running hwclock still give me the
"old" time setting?
_HRS_PM=-5
###
# https://stackoverflow.com/questions/1092631/get-current-time-in-seconds-since-the-epoch-on-linux-bash
_DTS=$(date +%s)
echo "// __ \$_DTS: |${_DTS}|";
_DTF=$(date --date @${_DTS})
echo "// __ \$_DTF: |${_DTF}|";
_NEW_DTS=$((_DTS+3600*_HRS_PM))
echo "// __ \$_NEW_DTS: |${_NEW_DTS}|";
# Convert the number of seconds back to date
_NEW_DTF=$(date --date @${_NEW_DTS})
echo "// __ \$_NEW_DTF: |${_NEW_DTF}|";
which hwclock
sudo hwclock --show
sudo hwclock --debug --set --date "${_NEW_DTF}"
sudo hwclock --show
date
// __ $_DTS: |1679606975|
// __ $_DTF: |Thu 23 Mar 2023 09:29:35 PM UTC|
// __ $_NEW_DTS: |1679588975|
// __ $_NEW_DTF: |Thu 23 Mar 2023 04:29:35 PM UTC|
hwclock from util-linux 2.36.1
Thu 23 Mar 2023 09:29:35 PM UTC
$ sudo hwclock --show
2023-03-23 16:30:23.685781+00:00
$ date
Thu 23 Mar 2023 09:31:40 PM UTC
Reply to: