Various date and time routines are available to determine system time, or convert it to local time, Greenwich Mean Time, arrays of date and time elements, or an ASCII character string.
The sample output column of the following table assumes the current date to be 2/24/97 7:11 pm Pacific Daylight Time. The third column shows what each routine returns, either when reporting the current time or when that date and time is passed to it in an appropriate argument. Full details of parameters and output are given in the description of each routine (A to Z Reference) in the Language Reference.
Portability Routine | Description | Sample output |
---|---|---|
CLOCK | Current time in "hh:mm:ss" format using a 24-hour clock | 19:11:00 |
CTIME | Converts a system time to a 24-character ASCII string | "Wed Feb 24 19:11:00 1999" |
DATE | A string representation of the current date | As a subroutine: "24-Feb-99"
As a function: "02/24/99" |
DTIME | Elapsed CPU time since later of (1) start of program, or (2) most recent call to DTIME | (/0.0, 0.0/)
(Actual results depend on the program and the system) |
ETIME | Elapsed CPU time since the start of program execution | (/0.0, 0.0/)
(Actual results depend on the program and the system) |
FDATE | The current date and time as an ASCII string | "Wed Feb 24 19:11:00 1999" |
GMTIME | Greenwich Mean Time as a 9-element integer array | (/0,12,03,24,2,97,3,55,0/) |
IDATE | Current date either as one 3-element array or three scalar parameters (month, day, year) | (1) (/24,2,1999/)
(2) month=2, day=24, year=99 |
ITIME | Current time as a 3-element array (hour, minute, second) | (/7,11,00/) |
JDATE | Current date as an 8-character string with the Julian date | "99055 " |
LTIME | Local time as a 9-element integer array | (/0,11,7,24,2,99,3,55,0/) |
RTC | Number of seconds
since 00:00:00 GMT, Jan 1, 1970 |
762145860 |
SECNDS | The number of seconds since midnight, less the value of its argument | 0.00 |
TIME | As a subroutine, returns the time formatted as hh:mm:ss
As a function, returns the time in seconds since midnight GMT Jan 1, 1970 |
Subroutine: "07:11:00"
Function: 762145860 |
TIMEF | The number of seconds since the first time this function was called (or zero) | 0.0 |
TIME and DATE are available as either a function or subroutine. Because of the name duplication, if your programs do not include the USE DFPORT statement, each separately compiled program unit can use only one of these versions. For example, if a program calls the subroutine TIME once, it cannot also use TIME as a function.
Standard Fortran 95/90 includes date and time intrinsic subroutines. For more information, see DATE_AND_TIME in the Language Reference.