Calculates the current calendar time.
Include
<time.h>
Prototype
time_t time(time_t *tod);
Argument
tod
Return Value
Returns the calendar time encoded as a value of time_t
.
Remarks
If the target environment cannot determine the time, the function returns -1
cast as a time_t
. By default, the compiler returns the time as
instruction cycles. This function is customizable (see pic30-libs
).
Example
#include <time.h>
#include <stdio.h>
volatile int i;
int main(void)
{
time_t ticks;
time(0); /* start time */
for (i = 0; i < 10; i++) /* waste time */
time(&ticks); /* get time */
printf("Time = %ld\n", ticks);
}
Example Output
Time = 256