Solved

Converting a COleDateTime to and from a string

Posted on 2004-03-25
4
3,075 Views
Last Modified: 2011-09-20
Hello experts

I have a string that I download from a database which holds a date
1039046400000 (the number of seconds from 1970)
I want to convert this string to a COleDateTime variable
After I do some work on the COleDateTime variable I want to convert it back in to a string ( the number of seconds from 1970 ).


My question is
How do I convert COleDateTime object to and from a string which contains the number of sec since 1970 ?

thank you for your time
0
Comment
Question by:funvill
  • 2
4 Comments
 
LVL 23

Expert Comment

by:chensu
Comment Utility
1. COleDateTime --> string

COleDateTime::Format()

2. string --> COleDateTime

COleDateTime::ParseDateTime()
0
 
LVL 8

Accepted Solution

by:
mnashadka earned 50 total points
Comment Utility
To get the COleDateTime, you would say:
time_t seconds = atoi("1039046400000");
COleDateTime date(seconds);

To get it back in that format:
time_t seconds = (date - COleDateTime(1970, 1, 1, 0, 0, 0)).GetTotalSeconds();
Then just do a sprintf or ostringstream or whatever to get that as a string.  Good luck.
0
 
LVL 23

Expert Comment

by:chensu
Comment Utility
Oops... I didn't read the question carefully.
0
 
LVL 2

Author Comment

by:funvill
Comment Utility
Thank you mnashadka
it works great
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now