We help IT Professionals succeed at work.

tm_wday

superabbe
superabbe asked
on
Medium Priority
1,693 Views
Last Modified: 2006-11-17
How do figure what day it is in a week ??
i want a func whitch gives me a number like 6 for sunday
or 0 as monday
asctime ????

Thanks superabbe@hotmail.com
Comment
Watch Question

Author

Commented:
sorry about the spelling
Its saturday and i'm having a good time !
Commented:
struct tm *tp = localtime(time(NULL));
tp->tm_wday; /* Sunday = 0, Monday = 6 */

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Commented:
Oops, sorry. More like this:
time_t t = time(NULL);
struct tm *tp = localtime(&t);
tp->tm_wday; /* Sunday = 0, Monday = 6 */

Author

Commented:
But can I make this statement now ?

if (tm_wday==0)
        printf("sunday");

Thanks
/Abbe

Commented:
Almost...
if (tp->tm_wday == 0)
      printf("sunday");

Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.