Current date and time as string

后端 未结 6 1864
梦毁少年i
梦毁少年i 2020-12-04 11:09

I wrote a function to get a current date and time in format: DD-MM-YYYY HH:MM:SS. It works but let\'s say, its pretty ugly. How can I do exactly the sam

6条回答
  •  眼角桃花
    2020-12-04 11:48

    #include 
    #include 
    
    int main()
    {
        std::time_t ct = std::time(0);
        char* cc = ctime(&ct);
    
        std::cout << cc << std::endl;
        return 0;
    }
    

提交回复
热议问题