Converts a date string into the default or a custom date format.
The function handles dates from 1582 to present day. If the date cannot be converted, the result string is empty.
string uConvertDate(datestring, inputformat [, outputformat])
uConvertDate("2005-06-27 00:00:00","y-M-D H:N:S","D mY") // returns "27 JUN 05"
uConvertDate("27 JUN 05", "D m Y") // returns "2005-06-27 00:00:00"
uConvertDate("27 JUN 05", "D m Y", "y-m-D 00:00:00") // returns "2005-06-27 00:00:00"
The function uConvertDate converts a date string into a different format using a source and a destination format string. The first parameter is the date string to be converted. The second parameter is a format string, specifying the date format of the input date (see list below). The outputformat parameter is optional; If omitted the date is converted using the format y-M-D H:N:S. The function handles dates from 1582 to present day. If the date cannot be converted, the result string is empty.
Identifier |
Description |
---|---|
Y |
Year 2-digits (06) |
y |
Year 4-digits (2006) |
C |
Century (20) |
M |
Month (03) |
m |
Month (JUN) |
D |
Day (12) |
H |
Hour (00 – 23) |
h |
Hour (01 – 12) |
N |
Minutes |
n |
Month (June) |
S |
Seconds |
s |
Hundredth of seconds |
t |
Thousandth of seconds |
A |
AM/PM |
d |
Day of month (05) |
E |
Day of year (001 – 366) |
G |
Week of year (01 – 52) |
F |
Week of month (1 – 6) |