Reputation: 47
I am working on a script that receives two inputs:
"%Y-%m-%dT%H:%M:%SZ”
)The script is supposed to find the offset and add it to the input timestamp, so when I run:
./TZ-converst.sh Asia/Kolkata 2016-12-07t00-00-00z
the output will be 2016-12-07t00-05-30z
.
The offset for each timezone comes easily:
offset="$(TZ=":$tz" date +%z )"
However, I am having a hard time adding this offset to the input time "2016-12-07t00-00-00z"
.
I am trying to use date -d
to use the input parameter but I keep getting
"usage: date [-jnu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...[-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]"
Any thoughts?
Upvotes: 0
Views: 426
Reputation: 70947
Print Time Zone Offset, according to summer time derivation, at a specific time:
TZ=Asia/Kolkata date -d '2016-12-07t00:00:00z' +%z
+0530
Care to keep syntax:
Year - Month - Day t Hours : Minutes : Seconds z
Upvotes: 1