How to fix C++ error: 'put_time' is not a member of 'std'

Problem:

While trying to compile your C++ application, you see an error message such as

example.txt
src/HTTPServer.cpp:12:16: error: 'put_time' is not a member of 'std'
     ss << std::put_time(std::localtime(&localTime), "%FT%H-%M-%SZ");;
                ^~~~~~~~

Solution

At the top of the file where this error occured, you need to add

example.cpp
#include <iomanip>

iomanip contains std::put_time() among other functionality.


Check out similar posts by category: C/C++, GCC Errors