Xbasic

Date and Time Format Elements

Description

A date format is created from the following date format elements.

To include separators in the formatted result, include separators in the format string. For example, "MON, d-yyyy". To use a format code a separator, precede the code with the escape character ("\").

Element

Description

Example Output

0

Format element (causes a time element h, m, or s, to be returned with a leading 0).

01, 08, 06

s

Second

33,5

1

Display fractional seconds to 1 decimal place.

.5

2

Display fractional seconds to 2 decimal places.

.13

3

Display fractional seconds to 3 decimal places.

.599

m

Minute

59,10,9

h

Hour

12, 1

a

12 hour clock with "a" or "p" suffix

a, p

am

12 hour clock with "am" or "pm" suffix

am, pm

A

12 hour clock with "A" or "P" suffix

A, P

AM

12 hour clock with "AM" or "PM" suffix

AM, PM

d

day (one digit)

3

dd

day spelled out (two digits, 0 pad)

03, 15

x

day with "st", "rd", "th" etc (e.g. 1st, 2nd, 23rd)

1st, 2nd, 23rd

X

day spelled out

First, Second, Twenty Third

W

weekday (three character, upper case)

SUN, MON

w

weekday (three character, lower case)

sun, mon

WEEKDAY

weekday (full name, upper case)

SUNDAY, MONDAY

weekday

weekday (full name, lower case)

sunday, monday

Weekday

weekday (full name, proper case)

Sunday, Monday

M

month (one digit)

1

MM

month (two digits, zero pad)

01, 10

MON

month (three character name, upper case)

JAN, FEB

mon

month (three character name, lower case)

jan, feb

Mon

month (three character name, proper case)

Jan, Feb

MONTH

month (full name, upper case)

JANUARY, FEBRUARY

month

month (full name, lower case)

january, february

Month

month (full name, proper case)

January, February

y

year (two digits)

99, 03

yy

year (two digits)

99, 03

yyyy

year (four digits)

1999, 2003

 Format Examples

curr = now()

? time("0h:0m a",curr)
= "11:39 a"

? time("dd-Month-yyyy",curr)
= "11-January-2018"

? time("Weekday, Mon dd, h:m am",curr)
= "Thursday, Jan 11, 11:39 am"

? time("X Weekday of Month",curr)
= "Eleventh Thursday of January"

? time("h:m:s.3",curr)
= "11:39:5.953"

? time("0h:0m:0s.3",curr)
= "11:39:05.953"

? time("Current \Mont\h: Month",curr)
= "Current Month: January"

See Also