From the course: Code Clinic: C++

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Convert time formats

Convert time formats - C++ Tutorial

From the course: Code Clinic: C++

Start my 1-month free trial

Convert time formats

- [Instructor] I often find working with timestamps as strings to be a frustrating experience because there are so many different ways they can be formatted. You might be given a value for just hours and minutes or hours, minutes, and seconds. Does that represent a 12 hour time format with AM and PM? Or a 24 hour time? Is that local time or UTC? And that's just figuring out the time. Dates can be formatted as year, month, day or month, day, year. The month could be a number or a word, and if it's a word, it's likely abbreviated in some way. And oh yeah, what symbol is used between each element? With all of these possible variations, it usually helps to convert string timestamps into a common format that's easier to work with. The standard ctime library is great for manipulating date and time information. However, to use it, I first need to convert my string timestamps into a data type supported by the library and…

Contents