Browse DevX
Sign up for e-mail newsletters from DevX


Minimize Date and Time Display Drudgery

Applications that display time and date often use tedious manual string formatting operations, making customization an ornery task. The problem is further aggravated when your app undergoes internationalization and localization. Find out how <ctime>'s strftime() function eases your time and date formatting pain.

any moons ago, I presented C++'s basic <ctime> time and date facilities. At that time, however, I didn't demonstrate how to format and customize the date and time. Such customizations may be needed when you localize an application, for example. Although internationalization and localization are notoriously complex, with some help from <ctime>'s function strftime(), you can eliminate much of this drudgery—at least as far as the time and date are concerned.

How do you format the date and time in an easy and portable manner?

Use the strftime() library function.

Thanks for your registration, follow us on our social networks to keep up-to-date