473,804 Members | 3,123 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4410
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.goo gle.com...
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****@linuxma il.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.l earn.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
3648
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 into the cookie and http header format(s)?
4
15181
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 used instead. private int ConvStdTimeToSec(string time) { return int.Parse(time.Substring(0,2)) * 3600 +
3
7780
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 seconds.
1
14605
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 = '2007-03-13T15:00:00Z' I want to convert it to my local time. start_time = time.mktime(time.strptime(start_time, '%Y-%m-%dT%H:%M:
5
20844
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 import strptime f1.write("strptime(%r); locale: %r" % (olddate, locale.getlocale())) newdate = time.strptime(olddate, "%H:%M:%S %b %d, %Y %Z") mysqldate = time.strftime("%Y-%m-%d %H:%M:%S", newdate)
0
923
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
4513
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 please help
0
3217
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 GMT+0:00. The conversion method from local time to UTC time is therefore different depending on the time of year. I need to calculate the time offset between local time and UTC time for any date in the year. Can anyone suggest a suitable method for...
1
1593
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 data in the (timestamp) and (loggedin) fields are in seconds and I'm trying to convert them to date and time. When I try to run this query I get this error:
2
5007
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 retrieve the time from the database the time will be like this... 2010-10-26 10:00:39 but i want only the time part. i.e 10:00:39
0
9708
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10340
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10324
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9161
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7623
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5527
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5662
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3827
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2998
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.