Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,906 questions

51,838 answers

573 users

How to print localtime struct tm details in C

1 Answer

0 votes
#include <stdio.h>
#include <time.h>

int main () {
   time_t timet;
   time(&timet);

   struct tm *p = localtime(&timet);

   printf("%d:%d:%d %d/%d/%d %d %d %d",
        p->tm_sec,         /* seconds,  range 0 to 59         */
        p->tm_min,         /* minutes, range 0 to 59          */
        p->tm_hour,        /* hours, range 0 to 23            */
        p->tm_mday,        /* day of the month, range 1 to 31 */
        p->tm_mon + 1,     /* month, range 0 to 11            */
        p->tm_year + 1900, /* The number of years since 1900  */
        p->tm_wday + 1,    /* day of the week, range 0 to 6   */
        p->tm_yday + 1,    /* day in the year, range 0 to 365 */
        p->tm_isdst);      /* daylight saving time            */
}





/*
run:

16:52:9 9/3/2022 4 68 0

*/



 



answered Mar 9, 2022 by avibootz

Related questions

1 answer 91 views
2 answers 164 views
164 views asked Jun 2, 2018 by avibootz
2 answers 160 views
160 views asked Jun 2, 2018 by avibootz
1 answer 178 views
178 views asked Dec 26, 2020 by avibootz
...