473,395 Members | 1,692 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to convert from time to UTC?

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
3 4375
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: | last post by:
First of all, I want to know if Cookie's expiration time and HTTP's header's last modified time are using the same format. Secondly, how do I format the time from a 10923023324324 kind of number...
4
by: tony | last post by:
Hello! I have this method ConvStdTimeToSec here that convert format hh:mm:ss into total number of seconds and return it. I just wonder if there exist a metod in the .NET framework that can be...
3
by: fmjoiner | last post by:
I have the code to convert a string into a int (the atoi function) but it only gives me the first number say if the time is 6:23:08 it only returns the number 6 but I need to change all of this to...
1
by: davelist | last post by:
I'm guessing there is an easy way to do this but I keep going around in circles in the documentation. I have a time stamp that looks like this (corresponding to UTC time): start_time =...
5
by: rouven | last post by:
Hi, i am trying to convert that time format '05:26:40 Jun 19, 2007 PDT' into mysql compatible format like YYYY-MM-DD HH:MM:SS. the code i tried was: from datetime import datetime from time...
0
by: dhanu sahu | last post by:
Hello friends, I am trying to convert datetime into integer, Ex- In dropdownlist 1- 9:30AM In dropdownlist 2- 6:PM I want total time as Thour=9:30AM-6:00PM,
2
by: nabil035 | last post by:
hi, wel I have these vars: double day,month,year,hour,minute,second,millisecond; I want to convert this data to a filetime structure, I don't want of course to convert them manually ...
0
by: Aandrew | last post by:
I need to be able to work out the UTC time given the local system time for any date in the year. I live in the UK and at the moment the time is GMT+1:00, however when we return to DST it will be...
1
by: dougancil | last post by:
I have the following sql query: SELECT .name, .Employeenumber, Convert (-(/1000)/60))/1440+1,"mm/dd/yy"as , FROM Employees INNER JOIN mOpInterval ON .Loginname1 = mOpInterval.Opname The...
2
by: impin | last post by:
i have stored the user break times in the database... user break start time and end time... the timestamp stored in the database in the (yyyy-mm-dd hh:mm:ss) format in the database... when i...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.