0

I wrote a code to generate the current date and time.. and I got the following result

Wed May 27 21:02:48 2020

I want to create an array of months and compare the months

string months[12] ={ "January", "February", "March", etc"};
string months[12] ={ "Jan","Feb","Mar",etc};

which one can I use so that it match with the c++ month format?

Dan
  • 1
  • 2
  • 1
    How did you produce the above date-time string (the one you want to compare against)? As you can see https://en.cppreference.com/w/cpp/io/manip/put_time it can be rather flexible. – Richard Critten May 27 '20 at 17:08
  • ``` time_t now = time(0); char* dt = ctime(&now); cout << "date and time is " << dt << endl; ``` – Dan May 27 '20 at 17:21
  • If I'm right, you wants to compare the month string returned by the system with your given month, it's a bit tough though. [Extracting year/month/day with std::chrono](https://stackoverflow.com/a/15958113/11471113). Look at the answer's **Update** section. There you can find your solution. – Rohan Bari May 27 '20 at 19:34

0 Answers0