Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8481887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:40:57+00:00 2026-06-10T19:40:57+00:00

I need to print out the current date in the following format : Today

  • 0

I need to print out the current date in the following format : Today is Wednesday – September 7, 2012. I know I will have to use the struct

 struct tm* time_info;

I can easily accomplish this using strftime(), however, I am tasked to NOT use strftime() and extract members of the struct directly using printf statements. I cannot seem to get it to properly work. Any clues? Here is my current code:

 #include <stdio.h>
 #include <sys/types.h>
 #include <time.h>
 #include <stdlib.h>

 /* localtime example */
 #include <stdio.h>
 #include <time.h>

 int main (void)
 {
 time_t t; 
 char buffer[40]; 
 struct tm* tm_info; 

 time(&t); 
 tm_info = localtime(&t);
 strftime(buffer, 40, " Today is %A - %B %e, %Y", tm_info); 
 puts(buffer); 


  return 0;
}

Instead of

 strftime(buffer, 40, " Today is %A - %B %e, %Y", tm_info); 

I need

 printf("Today is %s, struct members info in the correct format);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T19:40:59+00:00Added an answer on June 10, 2026 at 7:40 pm

    The struct tm has at least these members

    int    tm_sec   Seconds [0,60]. 
    int    tm_min   Minutes [0,59]. 
    int    tm_hour  Hour [0,23]. 
    int    tm_mday  Day of month [1,31]. 
    int    tm_mon   Month of year [0,11]. 
    int    tm_year  Years since 1900. 
    int    tm_wday  Day of week [0,6] (Sunday =0). 
    int    tm_yday  Day of year [0,365]. 
    int    tm_isdst Daylight Savings flag. 
    

    So now you can do e.g.

    printf("Today is %d - %d %d, %d", tm_info->tm_wday, 
                                      tm_info->tm_mon,
                                      tm->tm_mday,
                                      1900 + tm_info->tm_year);
    

    This ofcourse will print out the month and week day as numbers, I’ll leave it up to you to create a simple lookup table to get the matching English word. Use an array so you can map e.g. index 0 to “Sunday” , index 1 to “Monday” and so on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to print the date in the format of mm/dd/yyyy. if the date
I need to print out receipts that inserted into my database, and the latest
i need to print out numbers 1-100 in a random order. the print statement
The following code, prints out Derived Base Base But I need every Derived object
I have the following loop to calculate the dates of the current week and
I need a Java program to get the current date without a timestamp :
I need some help trying to figure out how to format dates in perl.
I have a datetime object, dt , that holds today's date. DateTime dt =
I'm currently working on a project where I need to print out a lesson
I need to create two date objects. If the current date and time is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.