Debian Codegraph @

doc/src/intrinsics/misc/date_and_time.md

raw
1 # date_and_time([date, time, zone, values]): Date and Time
2
3 Date and time subroutine.
4
5 ## Declaration
6
7 ### Syntax
8
9 ```fortran
10 call date_and_time([date, time, zone, values])
11 subroutine date_and_time(date, time, zone, values)
12 ```
13
14 ### Arguments
15
16 `date` the input value of character type, which has length 8 or larger. It is of
17 default kind. It is `intent(out)` and has form `ccyymmdd`.
18
19 `time` the input value of character type, which has length 10 or larger. It is
20 of default kind. It is `intent(out)` and has form `hhmmss.sss`.
21
22 `zone` the input value of character type, which has length 5 or larger. It is of
23 default kind. It is `intent(out)` and has from `(+-)hhmm`, representing the
24 difference with respect to Coordinates Universal Time (UTC). Unavailable time
25 and date parameters return blanks.
26
27 `values` the input value of integer type, 8 bits. It is `intent(out)`. It provides
28 the following:
29
30 - `value(1)`: The year.
31 - `value(2)`: The month.
32 - `value(3)`: The day of the month.
33 - `value(4)`: Time difference with UTC in minutes.
34 - `value(5)`: The hour of the day.
35 - `value(6)`: The minutes of the hour.
36 - `value(7)`: The seconds of the minutes.
37 - `value(8)`: The milliseconds of the second.
38
39 ### Return values
40
41 None.
42
43 ## Description
44
45 **date_and_time([date, time, zone, values])** reports the corresponding date
46 and time information from the real time system clock.
47
48 `date`, `time`, `zone`, `values` represents date, time, zone, and values as
49 decribed in arguments above.
50
51 Unavailable or errorneous date and time parameters return blanks.
52
53 ## Types
54
55 Supported input parameter types is real with `intent(out)`.
56
57 ```fortran
58 subroutine date_and_time(date, time, zone, values)
59 character(len=*), intent(out), optional :: date, time, zone
60 integer, intent(out), optional :: values(8)
61 end subroutine
62 ```
63
64 ## Examples
65
66 ```fortran
67 program intrinsics_date_and_time
68 implicit none
69 character(len=8) :: date
70 character(len=10) :: time
71 character(len=5) :: zone
72 integer,dimension(8) :: values
73 ! using keyword arguments
74 call date_and_time(date,time,zone,values)
75 call date_and_time(date=date,zone=zone)
76 call date_and_time(time=time)
77 call date_and_time(values=values)
78 print '(a,2x,a,2x,a)', date, time, zone
79 print '(8i5)', values
80 end program
81 ```
82
83 **Result:**
84
85 ```
86 20220812 075654.679 +0000
87 2022 8 12 0 7 56 54 679
88 ```
89
90 ## See Also
91
92 [cpu_time](cpu_time.md).