|
From: Per W. <pw...@ia...> - 2003-03-20 10:27:36
|
Actually time_t is normally an integer storing number of seconds since
1970.
localtime converts the number of seconds to a struct tm with time adjusted
for time zone and daylight savings.
gmtime converts the same number of seconds to a struct tm filled in with
UTC time, i.e. time-zone GMT without daylight savings.
For some systems, you might also do gettimeofday() to get sub-second time
resolution.
/Per W
On Thu, 20 Mar 2003, Ricardo L=F3pez Ruiz wrote:
> You can have different solutions as indicated in Schildt's book.
> For instance, one of them is:
>
> *********************
> #include <stdio.h>
> #include <stdlib.h>
> #include <time.h>
>
> int main()
> {
> struct tm *punt;
> time_t lt;
>
> lt=3Dtime(NULL);
> punt=3Dlocaltime(<);
> printf(asctime(punt));
>
> system("PAUSE");
> return 0;
> }
> **********************
>
> (1) time( ) gives the actual date and hour in a struct of type time_t;
> (2) localtime( ) separates the local time of the struct "lt" in a
> struct of type tm.
> (3) asctime( ) converts this information in a char array with the format:
> day month date hour: minutes:seconds year \n\0
>
> I hope this can help you.
>
> Ricardo.
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Tablet PC.
> Does your code think in ink? You could win a Tablet PC.
> Get a free Tablet PC hat just for playing. What are you waiting for?
> http://ads.sourceforge.net/cgi-bin/redirect.pl?micr5043en
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|