|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
time...without seconds in C!!
hi!
well i had been able to figure out how to get time in hours and minutes..not the seconds..... the following code gives me time as...10:30:23...hh:mm:sec i want only hh:min can anyone sugest how i can do this #include <time.h> #include <stdio.h> #define SIZE 256 int main (void) { char buffer1[SIZE]; char buffer2[SIZE]; time_t curtime; struct tm *loctime; /* Get the current time. */ curtime = time (NULL); /* Convert it to local time representation. */ loctime = localtime (&curtime); /* Print out the date and time in the standard format. */ fputs (asctime (loctime), stdout); /* Print it out in a nice format. */ strftime (buffer1, SIZE, " %x\n", loctime); printf("date: %s\n",buffer1); strftime (buffer2, SIZE, "%X", loctime); printf("time: %s\n",buffer2); return 0; } |
|
#2
|
||||
|
||||
|
Check out the other format specifiers on the man page for strftime (or in the help file entry for strftime).
Quote:
There are lots more options that look interesting, so I recommend reading it yourself. BTW, thanks. I had never looked at strftime before. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > time...without seconds in C!! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|