The DATE_AND_TIME subroutine retrieves information concerning a computer's calendar date, time of day and time zone at the time the subroutine is invoked.
SyntaxDATE_AND_TIME ([date [,]] [time[,]] [zone[,]] [values[,]] )
date is an INTENT(OUT) scalar of type CHARACTER, with a minimum length of eight. Its leftmost eight characters are set to a value of the form yyyymmdd, where yyyy is the year, mm the month, and dd the day. If there is no date available, date is blank.
time is an INTENT(OUT) scalar of type CHARACTER, with a minimum length of ten. Its leftmost ten characters are set to a value of the form hhmmss.sss, where hh is the hour, mm the minutes, and ss.sss is seconds and milliseconds. If there is no clock available, time is blank.
zone is an INTENT(OUT) scalar of type CHARACTER, with a minimum length of five. Its leftmost five characters are set to a value of the form +-hhmm, where hh and mm are the time difference with respect to Coordinated Universal Time (UTC, also known as Greenwich Mean Time) in hours and minutes. If there is no clock or time zone information available, zone is blank.
values is an INTENT(OUT) rank one array of type default INTEGER with a minimum size of eight. If any date or time value is unavailable, its corresponding element in values will be set to -huge(0). Otherwise, the first eight elements of values are as follows:
values(1) the year (for example, 2002)
values(2) the month of the year
values(3) the day of the month
values(4) the time difference with respect to Coordinated Universal Time (UTC) in minutes
values(5) the hour of the day, in the range of 0 to 23
values(6) the minutes of the hour, in the range of 0 to 59
values(7) the seconds of the minute, in the range 0 to 59
values(8) the milliseconds of the second, in the range 0 to 999
If keyword arguments are not used, the date value will always be returned in the first argument of the calling list, time in the second argument, zone in the third argument, and values in the fourth argument.
Examplecharacter(len=10) :: time,date,zone integer :: dt(8) call date_and_time(time=time) ! keyword arguments call date_and_time(date=date) ! call date_and_time(zone=zone) ! write(*,*) time,date,zone call date_and_time(date,time,zone) ! positional arguments write(*,*) time,date,zone call date_and_time(values=dt) write(*,*) dt call date_and_time(date) ! if no keywords are used, always call date_and_time(time) ! returns the date call date_and_time(zone) ! write(*,*) time,date,zone