473,587 Members | 2,473 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question on epoch time

Is the epoch time the number of seconds elapsed since January 1st 1970
in my timezone or as per UTC? I mean, if A's program makes a call to
time() in Melboune and B's program makes a call to time() in Montreal
AT THIS VERY INSTANT, will they return the same values, or will A's
program return a value that is more than B's value by 36000 (since
Melboune is 10 hours ahead of Montreal).

Thanks,
Anil

Jul 20 '07 #1
11 3689
On Jul 20, 2:48 pm, use...@sta.sams ung.com wrote:
Is the epoch time the number of seconds elapsed since January 1st 1970
in my timezone or as per UTC? I mean, if A's program makes a call to
time() in Melboune and B's program makes a call to time() in Montreal
AT THIS VERY INSTANT, will they return the same values, or will A's
program return a value that is more than B's value by 36000 (since
Melboune is 10 hours ahead of Montreal).

Thanks,
Anil

Sorry, I meant 14 hours ahead.

Jul 20 '07 #2
<us****@sta.sam sung.comwrote in message
news:11******** **************@ n2g2000hse.goog legroups.com...
Is the epoch time the number of seconds elapsed since January 1st 1970
in my timezone or as per UTC? I mean, if A's program makes a call to
time() in Melboune and B's program makes a call to time() in Montreal
AT THIS VERY INSTANT, will they return the same values, or will A's
program return a value that is more than B's value by 36000 (since
Melboune is 10 hours ahead of Montreal).
<OT>
It depends, since that's implementation-specific.

The POSIX epoch is defined as 1 Jan 1970 00:00:00 UTC. That's why folks in
the Western Hemisphere occasionally see dates of 31 Dec 1969 in odd places.

The DOS/Windows epoch is, IIRC, 1 Jan 1980 00:00:00 in the local timezone.
</OT>

Relying on there even _being_ an epoch, or that a time_t looks anything like
you expect, is unportable.

S

--
Stephen Sprunk "Those people who think they know everything
CCIE #3723 are a great annoyance to those of us who do."
K5SSS --Isaac Asimov
--
Posted via a free Usenet account from http://www.teranews.com

Jul 20 '07 #3
us****@sta.sams ung.com wrote:
Is the epoch time the number of seconds elapsed since January 1st 1970
in my timezone or as per UTC? I mean, if A's program makes a call to
time() in Melboune and B's program makes a call to time() in Montreal
AT THIS VERY INSTANT, will they return the same values, or will A's
program return a value that is more than B's value by 36000 (since
Melboune is 10 hours ahead of Montreal).
http://en.wikipedia.org/wiki/Epoch_(reference_date)
http://en.wikipedia.org/wiki/Unix_time

Pretty complete overview, along with the historical oddities. How
humans compute with time values is an interesting problem to solve
sometimes.
--
clvrmnky <mailto:sp***** *@clevermonkey. org>

Direct replies will be blacklisted. Replace "spamtrap" with my name to
contact me directly.
Jul 20 '07 #4
us****@sta.sams ung.com wrote:
>
Is the epoch time the number of seconds elapsed since January 1st 1970
in my timezone or as per UTC?
It's not specified by the C standard, but POSIX defines it to be per
UTC.

-Larry Jones

Some people just don't have inquisitive minds. -- Calvin
Jul 20 '07 #5
On Jul 20, 10:12 pm, "Stephen Sprunk" <step...@sprunk .orgwrote:

[I know that this is off-topic, but...]
The POSIX epoch is defined as 1 Jan 1970 00:00:00 UTC.
Where? I'd always believed that it was implementation defined,
but that time_t was required to contain seconds from some epoch,
but I can't find even that in the on line copy of the Posix
standard.

(It worries me, because I regularly use t1-t2 to get the elapsed
time in seconds, instead of difftime(), when portability is
limited to Unix. And now I learn that even that isn't
portable.)
Relying on there even _being_ an epoch, or that a time_t looks
anything like you expect, is unportable.
So it would seem. For a very large definition of "portable".
(Code that is only portable to Posix compliant C++ compilers is
still "portable". But apparently, this doesn't work even there.)

--
James Kanze (Gabi Software) email: ja*********@gma il.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Jul 22 '07 #6
On Jul 20, 10:50 pm, lawrence.jo...@ ugs.com wrote:
use...@sta.sams ung.com wrote:
Is the epoch time the number of seconds elapsed since January 1st 1970
in my timezone or as per UTC?
It's not specified by the C standard, but POSIX defines it to be per
UTC.
Since you're the real expert here: where? In
http://www.mail-archive.com/le******.../msg00109.html,
Landon Curt Noll describes what I had always believed to be the
case. (I didn't think that the epoch was fixed, but I definitly
recall the discussions concerning the handling of leap seconds.)
But I simply cannot find it in the on-line Posix standard; in
fact, I find a definite statement that "time_t and clock_t shall
be integer or real-floating types".

--
James Kanze (Gabi Software) email: ja*********@gma il.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Jul 22 '07 #7
On Jul 20, 11:02 pm, Clever Monkey <spamt...@cleve rmonkey.org.INV ALID>
wrote:
use...@sta.sams ung.com wrote:
Is the epoch time the number of seconds elapsed since January 1st 1970
in my timezone or as per UTC? I mean, if A's program makes a call to
time() in Melboune and B's program makes a call to time() in Montreal
AT THIS VERY INSTANT, will they return the same values, or will A's
program return a value that is more than B's value by 36000 (since
Melboune is 10 hours ahead of Montreal).
http://en.wikipedia.org/wiki/Epoch_(...wiki/Unix_time
Pretty complete overview, along with the historical oddities. How
humans compute with time values is an interesting problem to solve
sometimes.
Regretfully, the articles just repeat common knowledge, without
citing any real sources, so they don't mean anything. (All too
typical of Wikipedia, I fear.)

--
James Kanze (Gabi Software) email: ja*********@gma il.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Jul 22 '07 #8
James Kanze wrote:
On Jul 20, 10:50 pm, lawrence.jo...@ ugs.com wrote:
>use...@sta.sam sung.com wrote:
Is the epoch time the number of seconds elapsed since January 1st 1970
in my timezone or as per UTC?
>It's not specified by the C standard, but POSIX defines it to be per
UTC.

Since you're the real expert here: where?
I would think you find it in Section 4.14 [Seconds Since the Epoch]. See

http://www.opengroup.org/onlinepubs/009695399/
Best

Kai-Uwe Bux
Jul 22 '07 #9
On Jul 22, 2:21 pm, Kai-Uwe Bux <jkherci...@gmx .netwrote:
James Kanze wrote:
On Jul 20, 10:50 pm, lawrence.jo...@ ugs.com wrote:
use...@sta.sams ung.com wrote:
Is the epoch time the number of seconds elapsed since January 1st 1970
in my timezone or as per UTC?
It's not specified by the C standard, but POSIX defines it to be per
UTC.
Since you're the real expert here: where?
I would think you find it in Section 4.14 [Seconds Since the Epoch]. See
http://www.opengroup.org/onlinepubs/009695399/
Interesting. Now if there is only some text to somehow relate
time_t to "Seconds Since the Epoch". (The section you mention
doesn't mention time_t at all.)

I'd only looked for the definition of time_t itself before. A
quick search for "epoch" also turns up the specification for
mktime, where it says "The mktime() function shall convert the
broken-down time, expressed as local time, in the structure
pointed to by timeptr, into a time since the Epoch value with
the same encoding as that of the values returned by time()."
And I'm having a hard time figuring out what that is supposed to
mean (although the "with the same encoding as that of the values
returned by time()" certainly suggests that different encodings
are possible).

(Realistically, of course, any Unix system in which time_t was
not an integral value with the number of seconds since the
epoch, or at least since some epoch, would break so many
programs that it wouldn't be used. Or at least, I hope so,
since some of those programs would be my own:-).)

--
James Kanze (Gabi Software) email: ja*********@gma il.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Jul 22 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
6272
by: Mark | last post by:
I want to simply get the unix style epoch time (number of secs to now from Jan 01, 1970 UTC) for use as a timestamp to track the staleness of some objects. So I don't care about time zones or whatever as long as it's consistent. So I picked the epoch time UTC getting the value I wanted, "timestamp", this way: #include...
5
8502
by: Grey Alien | last post by:
I need to convert timestamps that are given as the number of seconds that have elapsed since midnight UTC of January 1, 1970, (not counting leap seconds). It seems all of the std C functions expect positive offsets from this date and are incapable of working on dates preceeding the epoch (i.e. negative offsets) - which IMHO shows a...
11
573
by: usenet | last post by:
Is the epoch time the number of seconds elapsed since January 1st 1970 in my timezone or as per UTC? I mean, if A's program makes a call to time() in Melboune and B's program makes a call to time() in Montreal AT THIS VERY INSTANT, will they return the same values, or will A's program return a value that is more than B's value by 36000 (since...
2
3513
by: Richard Rossel | last post by:
Hi friends, I need a little help here, I 'm stuck with epoch calculation issue. I have this datetime: date_new = datetime(*time.strptime('20080101T000000','%Y%m%dT%H%M%S') ) This date_new is in UTC Now I need to know the seconds since epoch of this new date, so I run this: seconds = int(time.mktime(date_new.timetuple())) but the seconds...
0
7918
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8206
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6621
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5713
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3840
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3875
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.