Reputation: 55
This is what i'm trying to do:
I want to create a simple shell script that checks the current timezone in the UK. i.e. BST or GMT.
I only can display the time for the current timezone the UK is in. i.e. UK is in GMT right now and I can only display that time. [TZ=GMT date]
Please note: I do not wish to permanently modify the UNIX time zone on the server (currently CET)
Based on that I need to do some calculations (which I'm fine with) I have already searched and I cannot find anything specific to this problem. Thank you for your help
Upvotes: 0
Views: 5003
Reputation: 53498
To get the date for a particular timezone, you can do:
TZ=GMT date
(Or date +%s
if you want epoch format, which is also TZ independent, but altogether friendlier for calculations. ).
For what it is now, relative time I think it's as simple as:
TZ=Europe/London date
Which I think should cause your system to report BST/GMT appropriately.
If you want it to specifically report the offset, you can use the %z
format specifier:
TZ=Europe/London date +"%Y%m%d %H:%M:%S %z"
Upvotes: 1