Next / Previous / Index / TCC Help System / Publications / Site map / NM Tech homepage

Getting the current date and time in Fortran

Tech Computer Center logo

To get the current date and time, declare two arrays of type integer*4, each with three elements. Then call the built-in idate and itime functions to place the day, month, and year into the first array and the hour, minute, and second into the second array:

      program when
      integer*4 today(3), now(3)
      call idate(today)   ! today(1)=day, (2)=month, (3)=year
      call itime(now)     ! now(1)=hour, (2)=minute, (3)=second
      write ( *, 1000 )  today(2), today(1), today(3), now
 1000 format ( 'Date ', i2.2, '/', i2.2, '/', i4.4, '; time ',
     &         i2.2, ':', i2.2, ':', i2.2 )
      stop
      end
Running this program might produce output something like this:
Date 04/01/1995; time 14:07:40

Next: Measuring elapsed time in a Fortran program
See also: Hints for Fortran programmers
Previous: Generating random numbers in Fortran
Site map
Index: Keyword index to help pages
Help: New Mexico Tech Computer Center: Help System
TCC Publications
Home: About New Mexico Tech

John Shipman, john@nmt.edu

Last updated: 1995/12/19 18:58:09 UT
URL: http://www.nmt.edu/tcc/help/lang/fortran/date.html