[ Previous ] [ Contents ] [ Index ] [ Next ]

ns_fmttime

Overview

Return a formatted date and time

Syntax

ns_fmttime time ?formatstring?

Description

ns_fmttime returns the specified date and time in a formatted string. This function behaves the same as the strftime function in C.

The time argument must specify the date and time as the number of seconds since 00:00:00 UTC, January 1, 1970. You can use the ns_time function to get the current time in this format.

You can use the following elements in the formatstring argument to specify how the returned string will be formatted. The default formatstring is "%a %b %d %T %Y".

Format Element

Description

%%

same as %

%a

locale's abbreviated weekday name

%A

locale's full weekday name

%b

locale's abbreviated month name

%B

locale's full month name

%c

locale's appropriate date and time representation

%C

locale's century number (the year divided by 100 and truncated)

%d

day of month ( 01 - 31 )

%D

date as %m/%d/%y

%e

day of month (1-31; single digits are preceded by a blank)

%h

locale's abbreviated month name

%H

hour ( 00 - 23 )

%I

hour ( 01 - 12 )

%j

day number of year ( 001 - 366 )

%m

month number ( 01 - 12 )

%M

minute ( 00 - 59 )

%n

same as new-line

%p

locale's equivalent of either AM or PM

%r

time as %I:%M:%S [AM|PM]

%R

time as %H:%M

%S

seconds ( 00 - 61 ), allows for leap seconds

%t

same as a tab

%T

time as %H:%M:%S

%U

week number of year ( 00 - 53 ), Sunday is the first day of week1

%w

weekday number ( 0 - 6 ), Sunday = 0

%W

week number of year ( 00 - 53 ), Monday is the first day of week 1

%x

locale's appropriate date representation

%X

locale's appropriate time representation

%y

year within century ( 00 - 99 )

%Y

year as ccyy ( e.g. 1986)

%Z

time zone name or no characters if no time zone exists

Examples

  1. Calling ns_fmttime as follows:

        ns_fmttime [ns_time]
    

    returns the date and time formatted like this:

        Wed Oct 29 15:42:11 1997
    

  2. Calling ns_fmttime as follows:

        ns_fmttime [ns_time] "%D %T"
    

    returns the date and time formatted like this:

        10/29/97 15:50:26
    

Top of Page

[ Previous ] [ Contents ] [ Index ] [ Next ]
Copyright © 1996 America Online, Inc.