Get locale short date from CTime MFC class (C++)



Here is the code to get locale short date from CTime MFC class (C++).

 
CString	FormatLocaleShortDate(CTime tm)
{
	CString strValue;
	SYSTEMTIME st;
	tm.GetAsSystemTime(st);
	GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, strValue.GetBufferSetLength(SMALL_TEXT_LENGTH), SMALL_TEXT_LENGTH);
	strValue.ReleaseBuffer();
	return strValue;
}


Leave a Reply

Your email address will not be published. Required fields are marked *