CRDate::format
Previous  Index  Next

CRString format(const char* format = NULL) const;

Return Value

CRString object that contains the formatted time.

Parameters

format
A formatting string is similar to the printf formatting string. Formatting codes are replaced by the corresponding CRDate class. Other characters in the formatting string are copied unchanged to the returned string. The value and meaning of the formatting codes for format are listed below:  
 
SpecifierDisplays  
 
dDisplays the day as a number without a leading zero (1-31).  
 
ddDisplays the day as a number with a leading zero (01-31).  
 
mDisplays the month as a number without a leading zero (1-12). If the m specifier immediately follows an h or hh specifier, the minute rather than the month is displayed.  
 
mmDisplays the month as a number with a leading zero (01-12). If the mm specifier immediately follows an h or hh specifier, the minute rather than the month is displayed.  
 
yyDisplays the year as a two-digit number (00-99).  
 
yyyyDisplays the year as a four-digit number (0000-9999).  
 
hDisplays the hour without a leading zero (0-23).  
 
hhDisplays the hour with a leading zero (00-23).  
 
nDisplays the minute without a leading zero (0-59).  
 
nnDisplays the minute with a leading zero (00-59).  
 
sDisplays the second without a leading zero (0-59).  
 
ssDisplays the second with a leading zero (00-59).  
 
tDisplays the time using the format given by the shortTimeFormat global variable.  
 
ttDisplays the time using the format given by the longTimeFormat global variable.  

When NULL or "" date is formatted as "dd.mm.yyyy".  

Description

Call this member function to create a formatted representation of the date/time value.

Example

CRDate date(1975, 7, 9, 17, 28);
CRString st;

// Format to "09.07.1975"
St = date.format();

// Format to "09-07-1975 17:28"
st = date.format("dd-mm-yyyy hh:nn");

See Also

CRDate::now


CRDate | Classes | OCL | Index