Docs.bmc.com will undergo a brief maintenance outage 27 March 2025. The site will be unavailable for ten minutes starting at 7:30 AM CDT/6 PM IST.

time()


Return the number of seconds since 00:00:00 GMT January 1, 1970.

Syntax

time()

Parameter

This function does not have any input parameters.

Description

The time() function returns the current local system time as the number of seconds that have elapsed since 00:00:00 GMT, Jan 01, 1970.

Example

The following is an example of the time() function:

function main() {
local seconds,current;
seconds = time();
current = asctime(seconds);
printf("seconds since 00:00:00 GMT January 1, 1970 : %d\n",seconds);
printf(" current date and time using asctime() : %s\n",current);
printf(" current date and time using date() : %s\n",date());
printf(" seconds using convert_date() : %d\n",convert_date(current));
}

The example produces the following output:

seconds since 00:00:00 GMT January 1, 1970 : 877458704
current date and time using asctime() : Tue Oct 21 13:31:44 1997
current date and time using date() : Tue Oct 21 13:31:44 1997
seconds using convert_date() : 877458704