C Library Functions  - now (3)

NAME

now(3f) - [M_time:DATE_PRINTING] return string representing current time given one of many formats to present with (LICENSE:MIT)

CONTENTS

Synopsis
Description
Options
Returns
Example
Author
License

SYNOPSIS

function now(format) result(timestr)

    character(len=*),intent(in)     :: format  ! input format string
    character(len=:),allocatable    :: timestr ! formatted date

DESCRIPTION

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.

OPTIONS

format string describing how to format the current date and time. For a complete description of the formatting macros supported see fmtdate_usage(3f).

RETURNS

timestr
  formatted output string representing date

EXAMPLE

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

AUTHOR

John S. Urban, 2015

LICENSE

    MIT


Nemo Release 3.1 now (3) February 23, 2025
Generated by manServer 1.08 from 03d4cda3-44b5-43ec-8ab0-a79b6bd4a6c7 using man macros.

Binary file (standard input) matches