date_and_time(3f) - [FORTRAN:INTRINSIC:SYSTEM ENVIRONMENT] gets current time
call date_and_time([date, time, zone, values])
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:
o value(1): - The year o value(2): - The month o value(3): - The day of the month o value(4): - Time difference with UTC in minutes o value(5): - The hour of the day o value(6): - The minutes of the hour o value(7): - The seconds of the minute o value(8): - The milliseconds of the second
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).
None
Sample program:
program demo_time_and_date implicit none 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), valuesend program demo_time_and_date
[[Fortran 95]] and later
Subroutine
cpu_time(3), system_clock(3)
date_and_time (3) | March 11, 2021 |