Example: Converting Time to Local Time

The following example uses localtime to convert the time_t variable, t, to a tm structure, now. It then changes the 24-hour field, tm_hour, to be 12-hour based and prints out the AM/PM time. The example then prints out details of the tm structure using strftime.