DATE_AND_TIME intrinsic subroutine

Standard: F77 F90 F95 F2003 F2008 F2018 Example program


<Syntax>

Call DATE_AND_TIME ( [ DATE , TIME , ZONE , VALUES ] )

DATE : default Character scalar, Intent(Out);
TIME : default Character scalar, Intent(Out);
ZONE : default Character scalar, Intent(Out);
VALUES : default Integer one-dimensional array, Intent(Out), minimum size 8. From Fortran 2018, non-default kind is allowed provided it can represent values in the range −9999 to +9999.

<Semantics>

DATE is assigned the current date in the format CCYYMMDD, where CC is the century number, YY is the year number (00-99), MM is the month (01-12) and DD is the day of the month (01-31); for example 20121109 for November 9, 2012.

TIME is assigned the current time of day in the format HHMMSS.sss, where HH is the hour of the day (00-23), MM is the minute (00-59), SS is the second (00-60) and sss is the millisecond (000-999); note that this allows for representation of leap seconds.

ZONE is assigned the time zone in the format +HHMM or -HHMM representing the offset (in hours and minutes) from UTC (colloquially known as Greenwich Mean Time).

To avoid losing information, DATE should be length 8, TIME should be length 10, and ZONE should be length 5. Prior to Fortran 2003, arguments shorter than the minimum length were not permitted. If an argument is longer than the minimum, the remainder of the argument will be set to blanks.

If the date, time, or time zone information is not available, that argument is assigned all blanks.

Each element of the VALUES argument is assigned the information as an integer: in order this is the year (including the century), month, day, time zone offset in minutes, hour, minutes, seconds, and milliseconds. If any of the information is not available, that element will be assigned the value -HUGE(VALUES).

Note that all arguments are optional.

<Related>

CPU_TIME intrinsic subroutine, SYSTEM_CLOCK intrinsic subroutine