| |

VerySource

 Forgot password?
 Register
Search
View: 738|Reply: 2

Neighborhoods! If time text output on MFC

[Copy link]

2

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-3-22 09:00:02
| Show all posts |Read mode
That's it!
Please master to rookie Thank you ~~~~~~
Reply

Use magic Report

0

Threads

14

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-6-29 01:45:01
| Show all posts
CTime time=CTime::GetCurrentTime();
CString string=time.Format("%Y-%M-%D %H:%M:%S");
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-3 18:15:01
| Show all posts
I wrote a function to get the current machine time, which can have different input parameters and output the time in different formats.
CString GetCurTime(TIME_TYPE nType)
{
// CString strFileName = "";
CString strTime = "";
CTime tmCur = CTime::GetCurrentTime();
switch(nType)
{
case DATE_LONG:
strTime = tmCur.Format("%Y-%m-%d %H:%M:%S");
break;
case DAY_NORMAL:
strTime = tmCur.Format("%Y%m%d");
break;
case TIME_NORMAL:
strTime = tmCur.Format("%H%M%S");
break;
case DATE_NORMAL:
strTime = tmCur.Format("%Y%m%d%H%M%S");
break;
case DAY_SHORT:
strTime = tmCur.Format("%m%d");
break;
case DAY_LONG:
strTime = tmCur.Format("%Y-%m-%d");
break;
case TIME_LONG:
strTime = tmCur.Format("%H:%M:%S");
break;
case MONTH_NORMAL:
strTime = tmCur.Format("%Y%m");
break;
case MONTH_LONG:
strTime = tmCur.Format("%Yyear%m");
break;
case TIME_NORAML:
strTime = tmCur.Format("%M%S");
break;
}
return strTime;
}
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list