Maxim_united
Maxim_united

Reputation: 2003

bash: convert hw timestamps to human and offset timezone

I have a script that reads files with linux timestamps and I'd like to convert them to human format while keeping the timezone offsets.

Script:

[..]
UPTIME=$(cut -d" " -f1 < /proc/uptime)
SECONDS=$(date +%s)
date -d"70-1-1 + $SECONDS sec - $UPTIME sec + $TIMESTAMP sec "   +"%d/%m/%Y %T"
[..]

The problem is that I have a +2h timezone offset, so that my script shows dates early by 2hours

date "+%z %Z"
+0200 IST

How can I adjust the script to use the timezone offset?

Thanks,

Upvotes: 0

Views: 974

Answers (1)

JuniorCompressor
JuniorCompressor

Reputation: 20025

You can use date with -u parameter which according to the manual it displays the output in UTC.

Upvotes: 1

Related Questions