TimeFormat

Returns the date and/or time as a text string in the indicated format.

Syntax:

TimeFormat (ymdhms,format)

Parameters:

(s) ymdhms  Date/time in YYYY:MM:DD:HH:MM:SS WIL time format.

(s) format  Indicates the date and/or time format to be returned by the function.  see below.

Returns:

(s) formatted date and/or time.  The maximum total expanded size of the returned string is limited to 2048 characters.

 

The following table lists the standard Windows date and time format characters accepted by the function.  Non-format characters are accepted but should be enclosed in single (') quotes to avoid non-format characters being used for date/time formatting.  In order to include a single quote in the returned text, escape it with a second single quote.  For example, '''' will create one single quote in the returned text.

Format

Used For

Description

d

Days

Displays the day as a number from 1 to 31

dd

Days

Displays the day as a number with a leading 0 if the number is less than 10

ddd

Weekdays

Displays a weekday name with 3 letters as Mon, Tue, etc

dddd

Weekdays

Displays the complete name of a week day as Monday, etc

M

Months

Displays the numeric month from 1 to 12

MM

Months

Displays the numeric month with a leading 0 if the number is less than 10

MMM

Months

Displays the short name of the month as Jan, Feb, Mar, etc

MMMM

Months

Displays the complete name of the month as January, etc

yy

Years

Displays two digits for the year as 00 for 2000 or 03 for 2003

yyyy

Years

Displays the numeric year with 4 digits

h

Hours

Hours with no leading zero for single-digit hours; 12-hour clock

hh

Hours

Hours with leading zero for single-digit hours; 12-hour clock

H

Hours

Hours with no leading zero for single-digit hours; 24-hour clock

HH

Hours

Hours with leading zero for single-digit hours; 24-hour clock

m

Minutes

Minutes with no leading zero for single-digit minutes

mm

Minutes

Minutes with leading zero for single-digit minutes

s

Seconds

Seconds with no leading zero for single-digit seconds

ss

Seconds

Seconds with leading zero for single-digit seconds

t

Time Mark

Two-character abbreviation (for example, AM or PM)*

* This function does not support single character time marks.
See Also:

FileTimeGet, FileTimeGetEx, TimeDate, TimeDayofWeek, TimeJulianDay, TimeJulToYmd, TimeYmdHms