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 8174865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:34:19+00:00 2026-06-06T22:34:19+00:00

I have a variable: char date[11]; , and I need to put inside it

  • 0

I have a variable: char date[11];, and I need to put inside it the current date, for example 29/06/2012.

So I’ll do something like:

printf ("%s\n", date);

And the output would be: 29/06/2012

I only found the option to print the date in words, like Fri, June 2012, but not the actual date in numbers.

So how can I print the current date in numbers?

  • 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-06T22:34:20+00:00Added an answer on June 6, 2026 at 10:34 pm

    You can reference this function strftime. I’ll let you figure out how to use it 🙂

    Since you claimed that you have searched for it, I’ll provide the answer:

    // first of all, you need to include time.h
    #include<time.h>
    
    int main() {
    
      // then you'll get the raw time from the low level "time" function
      time_t raw;
      time(&raw);
    
      // if you notice, "strftime" takes a "tm" structure.
      // that's what we'll be doing: convert "time_t" to "tm"
      struct tm *time_ptr;
      time_ptr = localtime(&raw);
    
      // now with the "tm", you can format it to a buffer
      char date[11];
      strftime(date, 11, "%d/%m/%Y", time_ptr);
    
      printf("Today is: %s\n", date);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have something like this: char *current_day, *current_time; system(date +%F); system(date +%T); It prints
I have a char variable, declared for example as: char a = 's'; How
I have 2 variable like below char s='s'; char Kaazoooombaa ='s'; how can I
I have variable which I populate from JSON formated data. Something like: var time=my_data[data.results[i].id].time;
If I have a variable like: char *sql; sql = insert into Norm1Tab values
I have a const char* variable which may have a value like OpenStack:OpenStack1. I
I have a global pointer variable char* pointer = new char[500]; /* some operations...
I have a single char(8) variable formatted as ddmmyyyy in a stored procedure (quality
I have a variable declared as const char *. I have allocated memory for
I have the following bit of code: As a global variable: char *orderFiles[10]; And

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.