getDate


String

getDate (String format)

Returns the current date as a formatted string according to format. See Table 1 below for details on the allowed patterns.

Parameters:

pattern - format pattern for the date

Returns:

The date as a string, or false if the pattern is invalid.

Example

str = getDate("hh:mm:ss")
// str contains the time of day, e.g. "09:46:32"
str2 = getDate("MM/dd/yyyy")
// str2 contains the date, e.g. "12/25/2008"

Format Specifications

Letter

Date or Time Component

Examples

y

Year

yyyy; yy

1996; 96

M

Month in year

MMMM;MMM;MM

July; Jul; 07

w

Week in year

w

27
W

Week in month

W

2
D

Day in year

D

189
d

Day in month

dd

10
F

Day of week in month

FF

2
E

Day in week

EEEE EEE

Tuesday; Tue

a

Am/pm marker

a

PM
H

Hour in day (0-23)

H

9
k

Hour in day (1-24)

k

24
K

Hour in am/pm (0-11)

K

0
h

Hour in am/pm (1-12)

h

12
m

Minute in hour

mm

30
s

Second in minute

ss

55
z

Time zone

zzzz zzz

Pacific Standard Time; PST

Z

GMT Time zone offset

Z

-0800

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*