Skip to content

Std::put time

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

GCC에서 컴파일 할 경우 아래와 같은 에러메시지가 출력될 수 있다.

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

이 현상은 GCC 4.9에서 나타나는 현상이다. GCC 5로 업데이트 하면 된다.

See also

Favorite site