Javascript Date / Time Formatting With Regular Expressions

This uses regular expressions and prototyped DATE functions to apply a date and time mask to a Javascript date object.

Date Mask
Time Mask

Resultant Date




Available Date Masks

d : Single digit day
dd : Two digit day
ddd : Three letter weekday abbreviation
dddd : Full weekday name
m : Single digit month
mm : Two digit month
mmm : Three letter month abreviation
mmmm : Full month name
yy : Two digit year
yyyy : Four digit year
short : Same as "m/d/yyyy"
medium : Same as "mmm d, yyyy"
long : Same as "mmmm d, yyyy"
full : Same as "dddd, mmmm d, yyyy"

Available Time Masks

h : Single digit 12-hour hour
hh : Two digit 12-hour hour
H : Single digit 24-hour hour
HH : Two digit 24-hour hour
m : Single digit minute
mm : Two digit minute
s : Single digit second
ss : Two digit second
l : Milliseconds
L : Three digit milliseconds
t : Single digit A / P
tt : Two digit AM / PM
short : Same as "h:mm tt"
medium : Same as "h:mm:ss tt"