This routine is not “Year 2000 Safe” because it returns only a two-digit value for the year. Programs that compute differences between dates using the output of this routine may not work properly after 31 December, 1999. Programs using this date() routine will see a runtime warning message the first time the routine is called to alert the user. See date_and_time() as a possible alternate routine.
The subroutine is called by:
call date( c ) |
|||
c |
CHARACTER*9 |
Output |
Variable, array, array element, or character substring |
The form of the returned string c is dd-mmm-yy, where dd is the day of the month as a 2-digit number, mmm is the month as a 3-letter abbreviation, and yy is the year as a 2-digit number (and is not year 2000 safe!).
Example: date:
demo% cat dat1.f * dat1.f -- Get the date as a character string. character c*9 call date ( c ) write(*,"(’ The date today is: ’, A9 )" ) c end demo% f95 dat1.f demo% a.out Computing time differences using the 2 digit year from subroutine date is not safe after year 2000. The date today is: 9-Jan-02 demo% |
See also idate() and date_and_time().
This is a Fortran 95 intrinsic routine, and is Year 2000 safe.
The date_and_time subroutine returns data from the real-time clock and the date. Local time is returned, as well as the difference between local time and Universal Coordinated Time (UTC) (also known as Greenwich Mean Time, GMT).
The date_and_time() subroutine is called by:
call date_and_time( date, time, zone, values ) |
|||
date |
CHARACTER*8 |
Output |
Date, in form CCYYMMDD, where CCYY is the four-digit year, MM the two-digit month, and DD the two-digit day of the month. For example: 19980709 |
time |
CHARACTER*10 |
Output |
The current time, in the form hhmmss.sss, where hh is the hour, mm minutes, and ss.sss seconds and milliseconds. |
zone |
CHARACTER*5 |
Output |
The time difference with respect to UTC, expressed in hours and minutes, in the form hhmm |
values |
INTEGER*4 VALUES(8) |
Output |
An integer array of 8 elements described below. |
The eight values returned in the INTEGER*4 values array are
VALUES(1) |
The year, as a 4-digit integer. For example, 1998. |
VALUES(2) |
The month, as an integer from 1 to 12. |
VALUES(3) |
The day of the month, as an integer from 1 to 31. |
VALUES(4) |
The time difference, in minutes, with respect to UTC. |
VALUES(5) |
The hour of the day, as an integer from 1 to 23. |
VALUES(6) |
The minutes of the hour, as an integer from 1 to 59. |
VALUES(7) |
The seconds of the minute, as an integer from 0 to 60. |
VALUES(8) |
The milliseconds of the second, in range 0 to 999. |
An example using date_and_time:
demo% cat dtm.f integer date_time(8) character*10 b(3) call date_and_time(b(1), b(2), b(3), date_time) print *,’date_time array values:’ print *,’year=’,date_time(1) print *,’month_of_year=’,date_time(2) print *,’day_of_month=’,date_time(3) print *,’time difference in minutes=’,date_time(4) print *,’hour of day=’,date_time(5) print *,’minutes of hour=’,date_time(6) print *,’seconds of minute=’,date_time(7) print *,’milliseconds of second=’,date_time(8) print *, ’DATE=’,b(1) print *, ’TIME=’,b(2) print *, ’ZONE=’,b(3) end |
When run on a computer in California, USA on February 16, 2000, it generated the following output:
date_time array values: year= 2000 month_of_year= 2 day_of_month= 16 time difference in minutes= -420 hour of day= 11 minutes of hour= 49 seconds of minute= 29 milliseconds of second= 236 DATE=20000216 TIME=114929.236 ZONE=-0700 |