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 yearvalue(2): - The monthvalue(3): - The day of the monthvalue(4): - Time difference with UTC in minutesvalue(5): - The hour of the dayvalue(6): - The minutes of the hourvalue(7): - The seconds of the minutevalue(8): - The milliseconds of the secondFortran 95 and later
Subroutine
call date_and_time([date, time, zone, values])
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
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