std::put_time formats

后端 未结 2 995
栀梦
栀梦 2021-01-14 08:24

I want understand how to work std::put_time, and how can I get date stamp in \"YYYY/MM/DD HH:MM:SS\" format. Now I write somthing like this:

std::chrono::tim         


        
相关标签:
2条回答
  • 2021-01-14 09:04

    As mentioned 1 hour ago here, cppreference has good documentation on this: http://en.cppreference.com/w/cpp/io/manip/put_time

    Specifically, you can get the format you described using the following format string:

    std::cout  << std::put_time(std::localtime(&now_c), "%Y/%m/%d %T")
    
    0 讨论(0)
  • 2021-01-14 09:08

    See this reference. It's actually the same as for the old strftime function, with some extra formats thrown in.

    0 讨论(0)
提交回复
热议问题