bash - Time zone to 24 hours -


i trying convert time zones usual format date +%z giving, 24 hour system.

what mean when ask for

# date +%z +0300 

i want get

# date +%z | something_in_awk_or_perl 3 

but, when

# date +%z -0700 

i want

# date +%z | something_in_awk_or_perl 17 

p.s. prefer one-line solution

thanks!

how using awk:

$ tz=utc-1 date +%:::z | awk 'begin{fs=ofs=":"}{$1=(24+$1)%24}1' 1  $ tz=utc+7:30 date +%:::z | awk 'begin{fs=ofs=":"}{$1=(24+$1)%24}1' 17:30 

if want decimal output, change output separator , divide 6:

$ tz=utc-1 date +%:::z | awk -f: 'begin{ofs="."}{$1=(24+$1)%24;$2/=6}1' 1.0  $ tz=utc+7:30 date +%:::z | awk -f: 'begin{ofs="."}{$1=(24+$1)%24;$2/=6}1' 17.5 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -