Click here to Skip to main content
15,888,733 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Is there any way to provide Date Time Value of any format as string, its format as string and get structure tm filled or object of type time_t (ctime). (function like strptime).
It should be available on windows.

Below link has strptime implementation, but i ma not sure if it is free software.

http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/time/strptime.c?rev=HEAD

Can anybody suggest?
Posted
Updated 14-Oct-13 22:33pm
v2

1 solution

C++

Hi,

I didn't exactly what you wanted but I hope following date conversion will give you some help

C#
int year;
int month;
int day;
char d[10];
char m[10];
char y[10];
char studyDateRange1[30];


VB
day   = m_studyDateRange1.GetDay();
month = m_studyDateRange1.GetMonth();
year  = m_studyDateRange1.GetYear();


C#
//convert int to char
_itoa(day,d,10);
_itoa(month,m,10);
_itoa(year,y,10);

sprintf (studyDateRange1, "%04d%02d%02d", year,month,day);


There is one more solution:
C#
CString dataToWrite;
dataToWrite = (CTime::GetCurrentTime()).Format("%m/%d/%Y %H:%M:%S");
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900