String to time converstion
-
Hi, I have a string have data of time format. like strTime = 06:45:18 I want to convert it into time object or store it into time variable , Becuase I want to take the time difference between to time that are actualy first stored in strings thanks Regards.
-
Hi, I have a string have data of time format. like strTime = 06:45:18 I want to convert it into time object or store it into time variable , Becuase I want to take the time difference between to time that are actualy first stored in strings thanks Regards.
Hi You can use the following function size_t strftime( char *strDest, size_t maxsize, const char *format, const struct tm *timeptr ); size_t wcsftime( wchar_t *strDest, size_t maxsize, const wchar_t *format, const struct tm *timeptr ); Wishes. Anshuman Dandekar Dare to Dream, Care to Achieve............. -- modified at 3:00 Tuesday 31st January, 2006
-
Hi You can use the following function size_t strftime( char *strDest, size_t maxsize, const char *format, const struct tm *timeptr ); size_t wcsftime( wchar_t *strDest, size_t maxsize, const wchar_t *format, const struct tm *timeptr ); Wishes. Anshuman Dandekar Dare to Dream, Care to Achieve............. -- modified at 3:00 Tuesday 31st January, 2006
He wants to convert a string object to time.
Jesus Lives Forever - Amen:rose:
--Owner drawn:rose: --An eye for an eye makes the whole world blind. --Jesus is Lord:rose:
-
He wants to convert a string object to time.
Jesus Lives Forever - Amen:rose:
--Owner drawn:rose: --An eye for an eye makes the whole world blind. --Jesus is Lord:rose:
-
AFAIK you have to write one by yourself. Could be tricky at times.
Jesus Lives Forever - Amen:rose:
--Owner drawn:rose: --An eye for an eye makes the whole world blind. --If you find my post helpful then do rate it. --Jesus is Lord:rose:
-
Hi, I have a string have data of time format. like strTime = 06:45:18 I want to convert it into time object or store it into time variable , Becuase I want to take the time difference between to time that are actualy first stored in strings thanks Regards.
The following code may help u.. i have Created and Debugged demo for U. Assumming that ur using MFC Application CString strTime="06:45:18"; CString h,m,s; SYSTEMTIME st; GetSystemTime(&st); h=strTime.Mid(0,2); m=strTime.Mid(3,2); s=strTime.Mid(6,2); sscanf(h.GetBuffer(2),"%d",&st.wHour); sscanf(m.GetBuffer(2),"%d",&st.wMinute); sscanf(s.GetBuffer(2),"%d",&st.wSecond); CTime t(st); //h.Format("%d:%d:%d",t.GetHour(),t.GetMinute(),t.GetSecond()); //AfxMessageBox(h); best luck. Thanks and Regards Laxman FAILURE is the first step towards SUCCESS :cool:
-
The following code may help u.. i have Created and Debugged demo for U. Assumming that ur using MFC Application CString strTime="06:45:18"; CString h,m,s; SYSTEMTIME st; GetSystemTime(&st); h=strTime.Mid(0,2); m=strTime.Mid(3,2); s=strTime.Mid(6,2); sscanf(h.GetBuffer(2),"%d",&st.wHour); sscanf(m.GetBuffer(2),"%d",&st.wMinute); sscanf(s.GetBuffer(2),"%d",&st.wSecond); CTime t(st); //h.Format("%d:%d:%d",t.GetHour(),t.GetMinute(),t.GetSecond()); //AfxMessageBox(h); best luck. Thanks and Regards Laxman FAILURE is the first step towards SUCCESS :cool:
Since your example uses MFC, why not simplify things by using
COleDateTime::ParseDateTime()
? For example:COleDateTime t;
t.ParseDateTime("06:45:18", VAR_TIMEVALUEONLY);
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli