You are on page 1of 2

DocumentationHome>FortranLibraryReference>Chapter1FORTRANLibraryRoutines>date_and_time:GetDateandTime

FortranLibraryReference
Previous:date:GetCurrentDateasaCharacterString Next:dtime,etime:ElapsedExecutionTime

date_and_time :GetDateandTime
ThisisaFORTRAN77versionoftheFortran90intrinsicroutine,andisYear2000safe.

The date_and_time subroutinereturnsdatafromtherealtimeclockandthedate.Localtimeisreturned,aswellasthedifferencebetween


localtimeandUniversalCoordinatedTime(UTC)(alsoknownasGreenwichMeanTime,GMT).

The date_and_time ()subroutineiscalledby:

calldate_and_time( date,time,zone,values )

date CHARACTER* 8 Output Date,informCCYYMMDD,whereCCYYisthefourdigityear,MMthetwodigitmonth,andDD


thetwodigitdayofthemonth.Forexample:19980709

time CHARACTER*10 Output Thecurrenttime,intheformhhmmss.sss,wherehhisthehour,mmminutes,andss.sss


secondsandmilliseconds.

zone CHARACTER*5 Output ThetimedifferencewithrespecttoUTC,expressedinhoursandminutes,intheformhhmm

values INTEGER*4 Output Anintegerarrayof8elementsdescribedbelow.


VALUES(8)

Theeightvaluesreturnedinthe INTEGER*4 valuesarrayare

VALUES(1) Theyear,asa4digitinteger.Forexample,1998.

VALUES(2) Themonth,asanintegerfrom1to12.

VALUES(3) Thedayofthemonth,asanintegerfrom1to31.

VALUES(4) Thetimedifference,inminutes,withrespecttoUTC.

VALUES(5) Thehouroftheday,asanintegerfrom1to23.

VALUES(6) Theminutesofthehour,asanintegerfrom1to59.
VALUES(7) Thesecondsoftheminute,asanintegerfrom0to60.

VALUES(8) Themillisecondsofthesecond,inrange0to999.

Anexampleusingdate_and_time:

demo% catdtm.f
integerdate_time(8)
character*10b(3)
calldate_and_time(b(1),b(2),b(3),date_time)
print*,'date_timearrayvalues:'
print*,'year=',date_time(1)
print*,'month_of_year=',date_time(2)
print*,'day_of_month=',date_time(3)
print*,'timedifferenceinminutes=',date_time(4)
print*,'hourofday=',date_time(5)
print*,'minutesofhour=',date_time(6)
print*,'secondsofminute=',date_time(7)
print*,'millisecondsofsecond=',date_time(8)
print*,'DATE=',b(1)
print*,'TIME=',b(2)
print*,'ZONE=',b(3)
end

WhenrunonacomputerinCalifornia,USAonJuly9,1998,itgeneratedthefollowingoutput:

date_timearrayvalues:
year=1998
month_of_year=7
day_of_month=9
timedifferenceinminutes=420
hourofday=17
minutesofhour=8
secondsofminute=54
millisecondsofsecond=587
DATE=19980709
TIME=170854.587
ZONE=0700

Previous:date:GetCurrentDateasaCharacterString Next:dtime,etime:ElapsedExecutionTime

2010,OracleCorporationand/oritsaffiliates

You might also like