Is there a standard date/time class in C++?

前端 未结 6 1229
悲哀的现实
悲哀的现实 2020-12-01 14:05

Does C++ stl have a standard time class? Or do I have to convert to c-string before writing to a stream. Example, I want to output the current date/time to a string stream:<

6条回答
  •  天涯浪人
    2020-12-01 14:30

    Not part of STL but well known library is boost.

    I would go the way of using boost::date. Here are some examples: http://www.boost.org/doc/libs/1_55_0/doc/html/date_time/date_time_io.html#date_time.io_tutorial.

    If you did not try out boost yet I encourage you to do so as it saves you from a lot of nasty issues, as it masks most OS dependent things like threading for example. Many things in boost are header only (template libraries). However datetime requires a lib or dll.

提交回复
热议问题