Jef*_*ain 1 coldfusion datetime
我有一个这样的约会:
2020-02-09:08:57:51
我如何将其转换为正确的日期和时间。
我试过了 #PARSEDATETIME(myd,"yyyy-MM-dd:HH:mm:ss")#
但它返回{ts '2024-09-09 08:00:51'} 这显然是不正确的。
与 类似dateTimeFormat,您必须在分钟内使用不同的字符:n
ts = "2020-02-09:08:57:51";
dt = parseDateTime(ts, "yyyy-mm-dd:HH:nn:ss");
writeOutput(dt);
// {ts '2020-02-09 08:57:51'}
Run Code Online (Sandbox Code Playgroud)
dt是一个日期对象,它的toString实现在 ColdFusion 中返回一个 ODBC 时间戳文字。
为了将来参考,这就是文档所说的:
d: Day of the month as digits; no leading zero for single-digit days.
dd: Day of the month as digits; leading zero for single-digit days.
EEE: Day of the week as a three-letter abbreviation.
EEEE: Day of the week as its full name.
m: Month as digits; no leading zero for single-digit months.
mm: Month as digits; leading zero for single-digit months.
mmm: Month as a three-letter abbreviation.
mmmm: Month as its full name.
M: Month in year.
D: Day in year. yy: Year as last two digits; leading zero for years less than 10.
yyyy: Year represented by four digits.
YYYY: Week year represented by four digits.
Y: Week year.
YY: Week year as last two digits; leading zero for years less than 10.
G: Period/era string. (e.g. BC, AD)
h: hours; no leading zero for single-digit hours (12-hour clock)
hh: hours; leading zero for single-digit hours (12-hour clock)
H: hours; no leading zero for single-digit hours (24-hour clock)
HH: hours; leading zero for single-digit hours (24-hour clock)
n: minutes; no leading zero for single-digit minutes
nn: minutes; a leading zero for single-digit minutes
s: seconds; no leading zero for single-digit seconds
ss: seconds; leading zero for single-digit seconds
l or L: milliseconds, with no leading zeros
t: one-character time marker string, such as A or P
tt: multiple-character time marker string, such as AM or PM
w: Week of the year as digit.
ww: Week of the year as digits. Leading zero for single-digit week.
W: Week of the month as digit.
WW: Week of the month as digits. Leading zero for single-digit week.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
323 次 |
| 最近记录: |