Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UTC time in strftime 1

Status
Not open for further replies.

tini1208

Technical User
Feb 13, 2006
56
DE
hi all,

i am using strftime to convert UTC seconds to a time format, but strftime uses the local system time (in my case gmt+1....summer and wintertime). my current code is:
Code:
OFS="\t"; print $3, strftime("%Y\t%m\t%d\t%H\t%M\t%S",time), lon, lat, ele
it there a possibility to use UTC time instead of system time?

thanks a lot....
 
TZ=UTC0 awk ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
thanks phv, but....mmmhhhhh.....i think it's more understandable, when i post the complete code. i am always using tcsh....force of habit.
Code:
#! /bin/tcsh -f

foreach i (`ls *.out`)

echo $i

set outfile = $i:r.1b

gawk '{if(NF==10)                                               \
       UTC=$1+946724400                                           \
       shot_time = $2/1000000                                      \
       lon = $5/1000000                                            \
       lat = $4/1000000                                            \
       ele = $6/1000                                               \
       ocElev = $7/1000                                            \
       oc_load = $8/1000                                           \
       sat = $9/1000                                               \
       sigma_ele = $10/1000                                        \
       OFS="\t"; print $3, strftime("%Y\t%m\t%d\t%H\t%M\t%S",UTC), lon, lat, ele-0.71, ocElev, oc_load, sat, sigma_ele\
}' $i > $outfile
echo "...Done"
end

the exportet utc seconds are advert to 1.1.2000 12:00, so i add the missing seconds to "real" utc.
so...TZ=UTC0 has to be added before the gawk command?
 
Perhaps this ?
setenv TZ=UTC0
gawk ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top