Function to create a human readable UTC date string.
The resulting string has 26 characters.
function utc_date_string() result(dat_string) ! -------------------------------------------------------------------- ! character(len=26) :: dat_string ! -------------------------------------------------------------------- ! integer, parameter :: year = 1 integer, parameter :: month = 2 integer, parameter :: day = 3 integer, parameter :: hour = 5 integer, parameter :: minute = 6 integer, parameter :: utc_diff = 4 character(len=9) :: u_off_string integer :: off_min, off_hour integer :: dat(8) ! -------------------------------------------------------------------- ! call date_and_time(values=dat) off_min = mod(dat(utc_diff),60) off_hour = dat(utc_diff)/60 if (dat(utc_diff) >= 0) then write(u_off_string,'(a4,i2.2,a1,i2.2)') 'UTC+', off_hour, ':', off_min else write(u_off_string,'(a3,i3.2,a1,i2.2)') 'UTC', off_hour, ':', off_min end if write(dat_string,'(i4,4(a1,i2.2),a10)') dat(year), '-', & & dat(month), '-', dat(day), ' ', dat(hour), ':', & & dat(minute), ' '//u_off_string end function utc_date_string