![]() |
| | #1 |
| Registered User Join Date: May 2006
Posts: 19
| How to get current time I only need the time, i don't need the date, year etc... How do i do that?? This is what i used: Code:
time_t t;
struct tm *local;
t = time(NULL);
local = localtime(&t);
...........
fprintf(file_out, "Arrival time: %s\n", asctime(local) );
...........
That's why i only need the time and not the dates etc.... Can anybody help me? |
| tsubasa is offline | |
| | #2 |
| DESTINY Join Date: Jul 2008 Location: in front of my computer
Posts: 656
| this is what u can do determine the time interval between two events. Code: clock_t start,end; start=clock(); //do something end=clock();
__________________ HOPE YOU UNDERSTAND....... for( ; ; ) printf("If you can't make it good, at least make it look good"); PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D. IDE- Microsoft Visual Studio 2008 Express Edition |
| BEN10 is offline | |
| | #3 |
| Registered User Join Date: Oct 2008 Location: TX
Posts: 1,262
| How about printing out just those elements of the struct tm object you're interested in instead of the whole thing. Just my 2c, but in this case it maybe better to take the difference of the begin and end times (epoch) instead of first converting them to a human-readable form and then taking their difference as the job may rollover to next day and those difference calculations will then be incorrect. |
| itCbitC is offline | |
| | #4 |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| You can also use difftime() to take the difference between to time_t values. -- Mats
__________________ Compilers can produce warnings - make the compiler programmers happy: Use them! Please don't PM me for help - and no, I don't do help over instant messengers. |
| matsp is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Journey time prog 1 minute wrong | mike_g | C Programming | 4 | 10-12-2006 03:41 AM |
| Military Time Functions | BB18 | C Programming | 6 | 10-10-2004 01:57 PM |
| Killing someones grandparents | nickname_changed | A Brief History of Cprogramming.com | 37 | 09-07-2003 07:56 AM |
| Is this really true or it's just science fiction? | Nutshell | A Brief History of Cprogramming.com | 145 | 04-09-2002 06:17 PM |
| time class | Unregistered | C++ Programming | 1 | 12-11-2001 10:12 PM |