Next: , Previous: CTIME, Up: Intrinsic Procedures


8.60 DATE_AND_TIME — Date and time subroutine

Description:
DATE_AND_TIME(DATE, TIME, ZONE, VALUES) gets the corresponding date and time information from the real-time system clock. DATE is INTENT(OUT) and has form ccyymmdd. TIME is INTENT(OUT) and has form hhmmss.sss. ZONE is INTENT(OUT) and has form (+-)hhmm, representing the difference with respect to Coordinated Universal Time (UTC). Unavailable time and date parameters return blanks.

VALUES is INTENT(OUT) and provides the following:

VALUE(1): The year
VALUE(2): The month
VALUE(3): The day of the month
VALUE(4): Time difference with UTC in minutes
VALUE(5): The hour of the day
VALUE(6): The minutes of the hour
VALUE(7): The seconds of the minute
VALUE(8): The milliseconds of the second

Standard:
Fortran 95 and later
Class:
Subroutine
Syntax:
CALL DATE_AND_TIME([DATE, TIME, ZONE, VALUES])
Arguments:

DATE (Optional) The type shall be CHARACTER(LEN=8) or larger, and of default kind.
TIME (Optional) The type shall be CHARACTER(LEN=10) or larger, and of default kind.
ZONE (Optional) The type shall be CHARACTER(LEN=5) or larger, and of default kind.
VALUES(Optional) The type shall be INTEGER(8).

Return value:
None
Example:
          program test_time_and_date
              character(8)  :: date
              character(10) :: time
              character(5)  :: zone
              integer,dimension(8) :: values
              ! using keyword arguments
              call date_and_time(date,time,zone,values)
              call date_and_time(DATE=date,ZONE=zone)
              call date_and_time(TIME=time)
              call date_and_time(VALUES=values)
              print '(a,2x,a,2x,a)', date, time, zone
              print '(8i5))', values
          end program test_time_and_date
     

See also:
CPU_TIME, SYSTEM_CLOCK