in reply to working with epoch seconds

There is nothing wrong with that output at all. gmtime gives you exactly what it says - GMT time. So unless you happen to be in the GMT timezone, there will always be a difference. For example, when I run your script on my local machine I get:
input time is 1160391190 gmtime gives: Mon Oct 9 10:53:10 2006 diff is: 28800
My local timezone is GMT+8 hours, so the output is correct.

Regards your local timezone being GMT+2, are you sure? Perhaps you are not taking something silly into account, like daylight savings?

As to what you should do about that, I'm afraid that I'm a little unclear on exactly what it is that you are trying to achieve - so perhaps you need to explain that a little more.

As a side note, you should try to avoid using $a and $b as variable names - they are special package global variables that are used by sort.

Cheers,
Darren :)

Replies are listed 'Best First'.
Re^2: working with epoch seconds
by jeanluca (Deacon) on Oct 09, 2006 at 11:30 UTC
    very interesting that you get 28800 (8 hours). I should have had 7200, but I get 3600.
    So, the output from strftime is in the localtime zone ?
    Any suggestions how to define the output timezone ?
    Thanks a lot
    LuCa

    UPDATE: This seems todo more or less what I need:
    use DateTime ; my $now = DateTime->now->set_time_zone("UTC") ; print $now->strftime("%s", time()) ;

      Use a module:

      use strict; use warnings; use DateTime; my $dt = DateTime->now; print $dt->strftime ("%Y %m %d, %H:%M:%S %Z\n"); $dt->set_time_zone ('America/New_York'); print $dt->strftime ("%Y %m %d, %H:%M:%S %Z\n"); __END__ 2006 10 09, 11:45:55 UTC 2006 10 09, 07:45:55 EDT

      Update: Ah, you figured it out. That's great :^).

      --
      David Serrano

        it seems to work :), but what is the difference between POSIX 'strftime' and DateTime::strftime ?

        LuCa