Skip to content
Search

Std::put time

lastmod 2018-08-17created 2015-05-092 edits

Current Time

auto now = std::chrono::system_clock::now();
auto now_c = std::chrono::system_clock::to_time_t(now);
std::cout << std::put_time(std::localtime(&now_c), "%c") << '\n';

Troubleshooting

put_time is not a member of std

When compiling with GCC, the following error message may be printed.

prog.cpp: In function 'int main()':
prog.cpp:14:18: error: 'put_time' is not a member of 'std'

This happens with GCC 4.9. Updating to GCC 5 fixes it.

See also

Favorite site