Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 03-09-2009
Member
 
Join Date: Jul 2009
Posts: 81
How to convert CString to CTime

I want to use system's date/time which is in mm/dd/yy format in code. But the problem is that the time that I am getting is not in ate/time format. So I want to change it to CTime format so that I can use it. How is this going to be possible? How can I convert the CString into CTIme format?
Reply With Quote
  #2  
Old 03-09-2009
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: How to convert CString to CTime

Code:
CTime stTime;
CTime *dynTime;

dynTime = new CTime(cstringYear,cstringMonth,cstringDay,cstringHour,cstringMin,cstringSec,cstringDsT);
stTime = dynTime;
delete dynTime;
In the above code, you call the system time and save it to your "stTime" and then use this variable in your code.
Reply With Quote
  #3  
Old 03-09-2009
Member
 
Join Date: May 2008
Posts: 685
Re: How to convert CString to CTime

Code:
COleDateTime myDtTime;
CTime sysTime;
if(myDtTime.ParseDateTime(strTimestampOther))
{
      SYSTEMTIME st;
      if(myDtTime.GetAsSystemTime(st))
      {
            sysTime = st;
       }
}
else
ASSERT(FALSE);
Reply With Quote
  #4  
Old 03-09-2009
Member
 
Join Date: Apr 2008
Posts: 2,001
Re: How to convert CString to CTime

I suppose it is not possible to convert a CString object to a CTime object. However if you still want to do so then you can format your time which is in string format into a CTime. You can also divide it into hours, minutes, seconds etc and manually create the CTime object.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to convert CString to CTime"
Thread Thread Starter Forum Replies Last Post
CString vs std:string Jai$Man Software Development 5 26-06-2011 07:41 PM
How to convert from ISO to DMG bevan Operating Systems 4 11-11-2010 07:47 AM
Finding ctime,mtime and atime John Wilson Operating Systems 5 12-03-2010 09:13 PM
C : Implementation of ctime() Gavyn Software Development 4 01-02-2010 04:21 PM
Convert video to iPod, Convert iTunes video, Convert DivX to MP4 tommyhills MediaCenter 1 26-07-2008 02:30 AM


All times are GMT +5.5. The time now is 06:00 AM.