unix time and strftime 
Author Message
 unix time and strftime

Probably something simple related to time zones or daylight savings
time maybe.  Difference in Greewich time?.  But I wondered how to
account for the anomally I see when converting Unix Epochal time
(seconds since Jan 1 1970 00:00:00)

Using awks strftime function to convert, I tired this.

If we use 120 seconds as a date it should be Jan 1 1970 02:00:00 I
guess right?

but converting it with awks strftime function gives a different
answer.

seconds=120
gawk -v s="$seconds" \
  'BEGIN {print strftime("%a %b %d %H:%M:%S %Z %Y",s)}'

Shows:
Wed Dec 31 16:02:00 PST 1969

What am I seeing here and how can I get an accurate conversion?



Wed, 20 Jul 2005 11:00:09 GMT  
 unix time and strftime


Quote:

>Probably something simple related to time zones or daylight savings
>time maybe.  Difference in Greewich time?.  But I wondered how to
>account for the anomally I see when converting Unix Epochal time
>(seconds since Jan 1 1970 00:00:00)

>Using awks strftime function to convert, I tired this.

>If we use 120 seconds as a date it should be Jan 1 1970 02:00:00 I
>guess right?

>but converting it with awks strftime function gives a different
>answer.

>seconds=120
>gawk -v s="$seconds" \
>  'BEGIN {print strftime("%a %b %d %H:%M:%S %Z %Y",s)}'

>Shows:
>Wed Dec 31 16:02:00 PST 1969

>What am I seeing here and how can I get an accurate conversion?

IIRC, there's an 8 timezone difference between GMT and PST.

HTH,

Chuck Demas

--
  Eat Healthy        |   _ _   | Nothing would be done at all,

  Die Anyway         |    v    | That no one could find fault with it.



Wed, 20 Jul 2005 13:48:25 GMT  
 unix time and strftime

Quote:

> Probably something simple related to time zones or daylight savings
> time maybe.  Difference in Greewich time?.  But I wondered how to
> account for the anomally I see when converting Unix Epochal time
> (seconds since Jan 1 1970 00:00:00)

> Using awks strftime function to convert, I tired this.

> If we use 120 seconds as a date it should be Jan 1 1970 02:00:00 I
> guess right?

Nope, 120 seconds = 2 minutes, so it ought to be Jan 1 1970 00:02:00,
provided that you allow for time zone differences.

Quote:
> but converting it with awks strftime function gives a different
> answer.

> seconds=120
> gawk -v s="$seconds" \
>   'BEGIN {print strftime("%a %b %d %H:%M:%S %Z %Y",s)}'

> Shows:
> Wed Dec 31 16:02:00 PST 1969

> What am I seeing here and how can I get an accurate conversion?

Wed Dec 31 16:02:00 PST 1969 == Thu Jan 01 00:02:00 UTC 1970

as Chuck says in his post, i.e., UTC (formerly GMT) = PST + 8
hours.

HTH
--
Peter S Tillier
"Who needs perl when you can write dc and sokoban in sed?"



Wed, 20 Jul 2005 18:17:56 GMT  
 unix time and strftime

Quote:
> Nope, 120 seconds = 2 minutes, so it ought to be Jan 1 1970 00:02:00,
> provided that you allow for time zone differences.

Egad I was using 2 minutes and looking for an answer for 2 hours.  
Gack ... should have been 120 * 60.


Thu, 21 Jul 2005 00:57:59 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. time.strftime BUG?

2. bug in time.strftime on linux???

3. time.strftime()

4. Convert time string to UNIX time

5. Unix time to calendar date/time?

6. GAWK: strftime("%z") and portability (which version of strftime is used in compile?)

7. Localized strftime() output

8. strftime * date calculations

9. Q: inverse of strftime

10. strftime weirdness

11. strftime year

12. strftime: %Z, timezone, and all that

 

 
Powered by phpBB® Forum Software