now(3f) - [M_time:DATE_PRINTING] return string representing current time given one of many formats to present with (LICENSE:MIT)
Synopsis
Description
Options
Returns
Example
Author
License
function now(format) result(timestr)
character(len=*),intent(in) :: format ! input format string character(len=:),allocatable :: timestr ! formatted date
The now(3f) function is a call to the fmtdate(3f) function using the current date and time. That is, it is a convenient way to print the current date and time.
format string describing how to format the current date and time. For a complete description of the formatting macros supported see fmtdate_usage(3f).
timestr formatted output string representing date
Sample Program:
program demo_now use M_time, only : now, locale implicit none ! MACROS write(*,*)now("The current date is & &%w, %l %d, %Y %H:%m:%s %N") ! If macros are not found substitute values for KEYWORDS write(*,*)now("The current date is & &year/month/day hour:minute:second timezone") write(*,*)now("The current date is & &longweekday at HOUR GOOD, longmonth shortday, year") ! including some HIGH-LEVEL KEYWORDS write(*,*)now("iso") ! and if no keywords are found, ABBREVIATED MACROS write(*,*)now("Y-M-D h:m:s") ! and basic INTERNATIONALIZATION is available call locale(french) write(*,*)now("%W, %L %D, %Y %h:%m:%s ") call locale(slovak) write(*,*)now("%W, %L %D, %Y %h:%m:%s ") call locale(spanish) write(*,*)now("%W, %L %D, %Y %h:%m:%s ") end program demo_now Results:
> The current date is Wed, Feb 5th, 2025 11:45:57 PM > The current date is 2025/02/05 23:45:57 -0500 > The current date is Wednesday at 11 PM, February 5th, 2025 > 2025-02-05T23:45:57-05:00 > 2025-02-05 23:45:57
John S. Urban, 2015
Nemo Release 3.1 | now (3) | February 23, 2025 |