Good day all,

I have a date string format say like "2010-03-01" and I want to get the "tm_wday" equivalent of it say like Monday, Tuesday ... Could someone give me a hint on how to achieve this in c. Thank you.

Populate struct tm with the date, set the time to some fictious number (if you don't do that the next step will fail), then call mktime(), which will populate all the rest of struct tm and return time_t value.

You will have to parse the string to extract the year, month and day. When you populate the struct tm you have to subtract 1900 from the year, and subtract 1 from the month.

struct tm can only handle a limited number of dates. You can not force it with a date before 1900.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.