<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: time() function dependent on timezone? in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/time-function-dependent-on-timezone/m-p/5105189#M91335</link>
    <description>&lt;!--!*#--&gt;After some editing of your source, I don't&lt;BR /&gt;see a problem with the time() or gmtime_r()&lt;BR /&gt;results:&lt;BR /&gt;&lt;BR /&gt;td176&amp;gt; echo $TZ ; ./tt ; export TZ=CST6CDT ; echo $TZ ; ./tt&lt;BR /&gt;EST5EDT&lt;BR /&gt;Timetick 1209031863&lt;BR /&gt;gmtime 2008-04-24 10:11:03 pre-isdst=0&lt;BR /&gt;local  2008-04-24 06:11:03 pre-isdst=1&lt;BR /&gt;CST6CDT&lt;BR /&gt;Timetick 1209031863&lt;BR /&gt;gmtime 2008-04-24 10:11:03 pre-isdst=0&lt;BR /&gt;local  2008-04-24 05:11:03 pre-isdst=1</description>
    <pubDate>Thu, 24 Apr 2008 09:13:22 GMT</pubDate>
    <dc:creator>Steven Schweda</dc:creator>
    <dc:date>2008-04-24T09:13:22Z</dc:date>
    <item>
      <title>time() function dependent on timezone?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/time-function-dependent-on-timezone/m-p/5105183#M91329</link>
      <description>Hi Folks,&lt;BR /&gt;&lt;BR /&gt;I got this query from my programming team. This is a rp3440 system with HP-UX 11.11.&lt;BR /&gt;&lt;BR /&gt;Subject: Unix System clock&lt;BR /&gt;&lt;BR /&gt;Description: In HP-UX the "man 3 time" function call gives following explanation.&lt;BR /&gt;Time() returns the time since 00:00:00 GMT, Jan. 1, 1970, measured in seconds.  This is the value of the UNIX system clock.&lt;BR /&gt; &lt;BR /&gt;This means number of seconds elapsed since 1/1/1970 00:00:00  irrespective of the timezone /daylight saving.&lt;BR /&gt; &lt;BR /&gt;When I execute the following program HP-UX machine :&lt;BR /&gt;main()&lt;BR /&gt;{&lt;BR /&gt;    time_t    t;&lt;BR /&gt;    struct tm ptm;&lt;BR /&gt; &lt;BR /&gt;    time(&amp;amp;t)&lt;BR /&gt;    printf("Timetick %d\n", t);&lt;BR /&gt; &lt;BR /&gt;    gmtime_r(&amp;amp;t, &amp;amp;ptm);&lt;BR /&gt;    printf( "\n 0 gtime  %04d-%02d-%02d %02d:%02d:%02d pre-isdst=0\n", ptm.tm_year + 1900, &lt;BR /&gt;    ptm.tm_mon + 1, ptm.tm_mday, ptm.tm_hour, ptm.tm_min, ptm.tm_sec, ptm.tm_isdst );&lt;BR /&gt;    &lt;BR /&gt;    localtime_r(&amp;amp;t, &amp;amp;ptm);&lt;BR /&gt;    printf( "\n 0 local  %04d-%02d-%02d %02d:%02d:%02d pre-isdst=0\n", ptm.tm_year + 1900, &lt;BR /&gt;    ptm.tm_mon + 1, ptm.tm_mday, ptm.tm_hour, ptm.tm_min, ptm.tm_sec, ptm.tm_isdst );&lt;BR /&gt;    return;&lt;BR /&gt;}&lt;BR /&gt; &lt;BR /&gt;Output is when TZ=GMT+4&lt;BR /&gt;timetick 1208790892&lt;BR /&gt; 0 gtime  2008-04-21 15:14:52 pre-isdst=0&lt;BR /&gt; 0 local  2008-04-21 11:14:52 pre-isdst=0&lt;BR /&gt; &lt;BR /&gt;Output is when TZ=TEST3:30&lt;BR /&gt;timetick 1208789056&lt;BR /&gt; 0 gtime  2008-04-21 14:44:16 pre-isdst=0&lt;BR /&gt; 0 local  2008-04-21 11:14:16 pre-isdst=0&lt;BR /&gt;Information Required:&lt;BR /&gt;from the above example time() function does depend on the timezone. Is it TRUE ? Is there any other function which will return number of seconds elapsed since 1970 at GMT+0/UTC. Which should not use the timezone or the daylight configurations.&lt;BR /&gt;&lt;BR /&gt;Useful answers will be rewarded with points.&lt;BR /&gt;&lt;BR /&gt;With regards,&lt;BR /&gt;Mohan.</description>
      <pubDate>Thu, 24 Apr 2008 05:26:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/time-function-dependent-on-timezone/m-p/5105183#M91329</guid>
      <dc:creator>Mohanasundaram_1</dc:creator>
      <dc:date>2008-04-24T05:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: time() function dependent on timezone?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/time-function-dependent-on-timezone/m-p/5105184#M91330</link>
      <description>Shalom Mohan,&lt;BR /&gt;&lt;BR /&gt;The time() function does not have any relation to timezone setting.&lt;BR /&gt;&lt;BR /&gt;Time is calculated by the number of seconds since January 1, 1970. Time zone merely controls display.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Thu, 24 Apr 2008 07:51:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/time-function-dependent-on-timezone/m-p/5105184#M91330</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2008-04-24T07:51:17Z</dc:date>
    </item>
    <item>
      <title>Re: time() function dependent on timezone?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/time-function-dependent-on-timezone/m-p/5105185#M91331</link>
      <description>If you want to know what time() does, print&lt;BR /&gt;the output from time() (in this case, "t"),&lt;BR /&gt;not the output from gmtime_r() or&lt;BR /&gt;localtime_r().</description>
      <pubDate>Thu, 24 Apr 2008 08:18:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/time-function-dependent-on-timezone/m-p/5105185#M91331</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2008-04-24T08:18:19Z</dc:date>
    </item>
    <item>
      <title>Re: time() function dependent on timezone?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/time-function-dependent-on-timezone/m-p/5105186#M91332</link>
      <description>Hi Steven,&lt;BR /&gt;&lt;BR /&gt;Thanks for your reply. In such a case is it not possible to see the time irrespective of the timezone?&lt;BR /&gt;&lt;BR /&gt;From the question I got, I understand that the programmer wants to display the time without the Timezone affecting its display. In other words, how can we display time irrespective of timezone, if possible.&lt;BR /&gt;&lt;BR /&gt;This topic is a bit alien to me and am not sure if I am asking the correct question here.&lt;BR /&gt;&lt;BR /&gt;With regards,&lt;BR /&gt;Mohan.</description>
      <pubDate>Thu, 24 Apr 2008 08:21:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/time-function-dependent-on-timezone/m-p/5105186#M91332</guid>
      <dc:creator>Mohanasundaram_1</dc:creator>
      <dc:date>2008-04-24T08:21:37Z</dc:date>
    </item>
    <item>
      <title>Re: time() function dependent on timezone?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/time-function-dependent-on-timezone/m-p/5105187#M91333</link>
      <description>&lt;!--!*#--&gt;gmtime[_r]() should be independent of any&lt;BR /&gt;time zone settings.  I'd expect&lt;BR /&gt;localtime[_r]() to depend on the time zone.&lt;BR /&gt;&lt;BR /&gt;    man localtime&lt;BR /&gt;&lt;BR /&gt;      localtime()       Correct for the time zone and any summer time zone&lt;BR /&gt;                        adjustments (such as Daylight Savings Time in the&lt;BR /&gt;                        USA), according to the contents of the TZ&lt;BR /&gt;                        environment variable (see Environment Variables&lt;BR /&gt;                        below). [...]</description>
      <pubDate>Thu, 24 Apr 2008 08:53:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/time-function-dependent-on-timezone/m-p/5105187#M91333</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2008-04-24T08:53:19Z</dc:date>
    </item>
    <item>
      <title>Re: time() function dependent on timezone?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/time-function-dependent-on-timezone/m-p/5105188#M91334</link>
      <description>Hi Steven Schweda,&lt;BR /&gt;&lt;BR /&gt;It is a bit of co-incidence that two Stevens replied to me :-)&lt;BR /&gt;&lt;BR /&gt;I have given your first reply to the people who raised the query. I will post an update based on their response. &lt;BR /&gt;&lt;BR /&gt;I will assign points to you during this update. Thanks for your time.&lt;BR /&gt;&lt;BR /&gt;With regards,&lt;BR /&gt;Mohan.</description>
      <pubDate>Thu, 24 Apr 2008 09:01:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/time-function-dependent-on-timezone/m-p/5105188#M91334</guid>
      <dc:creator>Mohanasundaram_1</dc:creator>
      <dc:date>2008-04-24T09:01:55Z</dc:date>
    </item>
    <item>
      <title>Re: time() function dependent on timezone?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/time-function-dependent-on-timezone/m-p/5105189#M91335</link>
      <description>&lt;!--!*#--&gt;After some editing of your source, I don't&lt;BR /&gt;see a problem with the time() or gmtime_r()&lt;BR /&gt;results:&lt;BR /&gt;&lt;BR /&gt;td176&amp;gt; echo $TZ ; ./tt ; export TZ=CST6CDT ; echo $TZ ; ./tt&lt;BR /&gt;EST5EDT&lt;BR /&gt;Timetick 1209031863&lt;BR /&gt;gmtime 2008-04-24 10:11:03 pre-isdst=0&lt;BR /&gt;local  2008-04-24 06:11:03 pre-isdst=1&lt;BR /&gt;CST6CDT&lt;BR /&gt;Timetick 1209031863&lt;BR /&gt;gmtime 2008-04-24 10:11:03 pre-isdst=0&lt;BR /&gt;local  2008-04-24 05:11:03 pre-isdst=1</description>
      <pubDate>Thu, 24 Apr 2008 09:13:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/time-function-dependent-on-timezone/m-p/5105189#M91335</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2008-04-24T09:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: time() function dependent on timezone?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/time-function-dependent-on-timezone/m-p/5105190#M91336</link>
      <description>Hi Steven Schweda,&lt;BR /&gt;&lt;BR /&gt;Your Last post is encouraging. May I ask you what kind of edit was done on the source? This may solve my problem altogether.&lt;BR /&gt;&lt;BR /&gt;With regards,&lt;BR /&gt;Mohan.</description>
      <pubDate>Thu, 24 Apr 2008 09:50:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/time-function-dependent-on-timezone/m-p/5105190#M91336</guid>
      <dc:creator>Mohanasundaram_1</dc:creator>
      <dc:date>2008-04-24T09:50:06Z</dc:date>
    </item>
    <item>
      <title>Re: time() function dependent on timezone?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/time-function-dependent-on-timezone/m-p/5105191#M91337</link>
      <description>&amp;gt;In HP-UX the "man 3 time"&lt;BR /&gt;&lt;BR /&gt;That's time(2), it is a system call.  ctime(3) are a libc functions.&lt;BR /&gt;&lt;BR /&gt;Some minor performance tweaks: time(&amp;amp;t)&lt;BR /&gt;Don't do this, it makes the kernel sweat.  Instead do:&lt;BR /&gt;t = time(NULL);&lt;BR /&gt;&lt;BR /&gt;&amp;gt;printf("Timetick %d\n", t);&lt;BR /&gt;&lt;BR /&gt;The type of time_t is long, so use:&lt;BR /&gt;printf("Timetick %ld\n", t);&lt;BR /&gt;&lt;BR /&gt;&amp;gt;how can we display time irrespective of timezone, if possible.&lt;BR /&gt;&lt;BR /&gt;You can't.  All times must be relative to some time zone, possibly UTC, unless you want to see the raw time_t decimal number.</description>
      <pubDate>Thu, 24 Apr 2008 10:21:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/time-function-dependent-on-timezone/m-p/5105191#M91337</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-04-24T10:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: time() function dependent on timezone?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/time-function-dependent-on-timezone/m-p/5105192#M91338</link>
      <description>&lt;!--!*#--&gt;&amp;gt; [...] what kind of edit [...]?&lt;BR /&gt;&lt;BR /&gt;Enough to get it through the compiler.&lt;BR /&gt;&lt;BR /&gt;td192&amp;gt; cat tt.c&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;TIME.H&gt;&lt;BR /&gt;&lt;BR /&gt;main()&lt;BR /&gt;{&lt;BR /&gt;time_t t;&lt;BR /&gt;struct tm ptm;&lt;BR /&gt;&lt;BR /&gt;time(&amp;amp;t);&lt;BR /&gt;printf("Timetick %d\n", t);&lt;BR /&gt;&lt;BR /&gt;gmtime_r(&amp;amp;t, &amp;amp;ptm);&lt;BR /&gt;printf( "gmtime %04d-%02d-%02d %02d:%02d:%02d pre-isdst=%d\n",&lt;BR /&gt; ptm.tm_year + 1900, ptm.tm_mon + 1, ptm.tm_mday,&lt;BR /&gt; ptm.tm_hour, ptm.tm_min, ptm.tm_sec, ptm.tm_isdst );&lt;BR /&gt;&lt;BR /&gt;localtime_r(&amp;amp;t, &amp;amp;ptm);&lt;BR /&gt;printf( "local  %04d-%02d-%02d %02d:%02d:%02d pre-isdst=%d\n",&lt;BR /&gt; ptm.tm_year + 1900, ptm.tm_mon + 1, ptm.tm_mday,&lt;BR /&gt; ptm.tm_hour, ptm.tm_min, ptm.tm_sec, ptm.tm_isdst );&lt;BR /&gt;&lt;BR /&gt;return 0;&lt;BR /&gt;}&lt;BR /&gt;&lt;/TIME.H&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Thu, 24 Apr 2008 13:38:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/time-function-dependent-on-timezone/m-p/5105192#M91338</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2008-04-24T13:38:06Z</dc:date>
    </item>
    <item>
      <title>Re: time() function dependent on timezone?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/time-function-dependent-on-timezone/m-p/5105193#M91339</link>
      <description>&amp;gt; The type of time_t is long, so use:&lt;BR /&gt;&amp;gt; printf("Timetick %ld\n", t);&lt;BR /&gt;&lt;BR /&gt;And what do you need to do to make "long"&lt;BR /&gt;different from "int"?</description>
      <pubDate>Thu, 24 Apr 2008 13:47:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/time-function-dependent-on-timezone/m-p/5105193#M91339</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2008-04-24T13:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: time() function dependent on timezone?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/time-function-dependent-on-timezone/m-p/5105194#M91340</link>
      <description>&amp;gt; Steven: And what do you need to do to make "long" different from "int"?&lt;BR /&gt;&lt;BR /&gt;(Use C++? :-)&lt;BR /&gt;Compile in 64 bit mode (+DD64) because you want the time to go past 2038 for your mortgages.&lt;BR /&gt;&lt;BR /&gt;warning #2181-D: argument is incompatible with&lt;BR /&gt;corresponding format string conversion&lt;BR /&gt;printf("Timetick %d\n", t);&lt;BR /&gt;</description>
      <pubDate>Fri, 25 Apr 2008 00:16:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/time-function-dependent-on-timezone/m-p/5105194#M91340</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-04-25T00:16:51Z</dc:date>
    </item>
    <item>
      <title>Re: time() function dependent on timezone?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/time-function-dependent-on-timezone/m-p/5105195#M91341</link>
      <description>Hi Folks,&lt;BR /&gt;&lt;BR /&gt;I am closing this thread as I have not heard from the originator as of now. I have given this link for them to follow and I am sure your suggestions were very useful.&lt;BR /&gt;&lt;BR /&gt;Thanks for both the Steven and Dennis. The answers you have provided were informative and very useful. I have assigned points to all the people who replied.&lt;BR /&gt;&lt;BR /&gt;With regards,&lt;BR /&gt;Mohan.</description>
      <pubDate>Sun, 04 May 2008 05:34:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/time-function-dependent-on-timezone/m-p/5105195#M91341</guid>
      <dc:creator>Mohanasundaram_1</dc:creator>
      <dc:date>2008-05-04T05:34:53Z</dc:date>
    </item>
  </channel>
</rss>

