By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,159 Members | 882 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,159 IT Pros & Developers. It's quick & easy.

How to convert from time to UTC?

P: n/a
Hi.
I grabbed the date and time at compile time of my c++ codes. The
values returned are like

Aug 11 2004 and 12:30:04 .

I would like to convert these into UTC. Can this be done. I've
searched the net for hours but to my surprise, there dont seem to be a
simple function that can do such a conversion? I must be missing
something somewhere. Any pointers are appreciated. Thanks.
Jul 22 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
The "time" function returns the number of seconds elapsed since 00:00:00
Greenwich mean time (GMT), January 1, 1970, according to the system clock.
Then use "ctime" to convert the time_t returned value to a character string.
Well, I don't know if you are using __TIME__ to get the compile time, but I
think you can substitute this by some inline function using the time
functions above.

"kackson" <ka*****@yahoo.com> wrote in message
news:90**************************@posting.google.c om...
Hi.
I grabbed the date and time at compile time of my c++ codes. The
values returned are like

Aug 11 2004 and 12:30:04 .

I would like to convert these into UTC. Can this be done. I've
searched the net for hours but to my surprise, there dont seem to be a
simple function that can do such a conversion? I must be missing
something somewhere. Any pointers are appreciated. Thanks.

Jul 22 '05 #2

P: n/a
kackson writes:
I grabbed the date and time at compile time of my c++ codes. The
values returned are like

Aug 11 2004 and 12:30:04 .

I would like to convert these into UTC. Can this be done. I've
searched the net for hours but to my surprise, there dont seem to be a
simple function that can do such a conversion? I must be missing
something somewhere. Any pointers are appreciated. Thanks.


I am confused by your question. You speak of "grabbing" the time and date
and these values being "returned". I am familiar with the process in the
preprocessor of *printing* the time and date but having the compiler return
these value to you sounds foreign. I have the impression that you want the
compiler to print UCT time but that isn't what I read. Do you care to
clarify? In the meantime, you might look at mktime() in <ctime> to see if
that is of any interest. Note that your post didn't address the daylight
saving time issue, so it may not be a completely definitive example.
Jul 22 '05 #3

P: n/a
On Wed, 11 Aug 2004 11:34:47 -0300, "Marcelo" <ms****@linuxmail.org>
wrote in comp.lang.c++:

Please don't top post. Material you add in a reply belongs AFTER
quoted material you are commenting on, as I did below. There are
patches for Microsoft's boorish excuse for a virus catcher, er,
newsreader, to correct its ignorant default behavior of putting the
cursor at the top. Google for one and install it.
The "time" function returns the number of seconds elapsed since 00:00:00
Greenwich mean time (GMT), January 1, 1970, according to the system clock.


This is neither required nor guaranteed by C++. It happens to be true
on some systems, not true on others. C++ inherits its definition of
time_t and time() from ISO C. The only guarantee is that time_t is an
arithmetic type. Nothing is specified about its resolution or
interpretation.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Jul 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.