Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]


How to format the date and time

Use TTime::FormatL() to format the date while honouring all locale-dependent settings, including the date separator characters, and whether the date format should be European, American or Japanese.

This function should also be used to format the locale-dependent aspects of the time, including the time separator characters, whether a 12 or 24 hour clock is to be used, and whether am/pm text should be located before or after the time.

TTime homeTime;
TBuf<32> buf;

// get home time and format it locale dependently
homeTime.HomeTime();

_LIT(KFormatTxt,"%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%:3%+B");
homeTime.FormatL(buf,KFormatTxt); 

// This gives 19/05/1997 9:44:51 am, assuming 12 hour clock with     
// trailing am/pm text, am/pm space between, and European date format