js文件在:a9engine/com/trydofor/a9js/format/date.js
测试页面在:a9engine/__testdemo__/com_trydofor_a9js_format/test-date_format.htm
下面是使用方法:
/**
UTF8(BOM) GPL trydofor.com May.2007
===========================================================
DateFormatClass
like the java's SimpleDateFormat.
Letter Date or Time Component Presentation Examples UserDic
y Year Year 1996; 96
M Month in year Month July; Jul; 07 *
d Day in month Number 10
E Day in week Text Tuesday; Tue; 2 *
a Am/pm marker Text pm,p *
H Hour in day (0-23) Number 0
h Hour in am/pm (1-12) Number 12
m Minute in hour Number 30
s Second in minute Number 55
S Millisecond Number 978
Date and Time Pattern Result
"yyyy.MM.dd 'at' HH:mm:ss" 2001.07.04 at 12:08:56
"EEE, MMM d, ''yy" Wed, Jul 4, '01
"h:mm a" 12:08 p
"hh 'o''clock' aa" 12 o'clock pm
"yyyyy.MMMMM.dd hh:mm aaa" 2001.July.04 12:08 pm
"EEE, d MMM yyyy HH:mm:ss" Wed, 4 Jul 2001 12:08:56
"yyMMddHHmmss" 010704120856
"'''ad'''yyyy'year'MM'month'dd''" 'ad'2007year06month16'
"MM'yyyy''yyyy'yyyy" 06yyyy'yyyy2007
String format(formatStr,date,userDic)
将日期格式化成设定的格式.
formatStr: 格式化字符串(参考上面说明)
date: 需要格式化的日期,为空时,使用当前时间
userDic: 替换默认的显示(ampm,month,week)
格式:
userDic = {M:[[简称,全程],],E:[[简称,全称],],a:[[简称,全称],]}
userDic = {
M:[
['Sun','Sunday'],
['Mon','Monday'],
['Tue','Tuesday'],
['Wed','Wednesday'],
['Thu','Thursday'],
['Fri','Friday'],
['Sat','Saturday']
],
E:[
['Jan','January'],
['Feb','Feburary'],
['Mar','March'],
['Apr','April'],
['May','May'],
['Jun','June'],
['Jul','July'],
['Aug','August'],
['Sep','September'],
['Oct','October'],
['Nov','November'],
['Dec','December']
],
a:[['a','am'],['p','pm']]
}
*/