1
+ <h3>format_date() function</h3>
2
+ Format a date type or string into a custom string format. Uses Qt data time format strings. See <a href='http://qt-project.org/doc/qt-4.8/qdatetime.html#toString'>QDateTime::toString</a>
3
+
4
+ <h4>Syntax</h4>
5
+ <code>format_date('string', 'format_string')</code><br>
6
+
7
+ <h4>Arguments</h4>
8
+ <code>string</code> - is string. Date/Time/DateTime string.
9
+ <br>
10
+ <code>format_string</code> - is string. String template used to format the string.
11
+
12
+ <table>
13
+ <thead>
14
+ <tr>
15
+ <th>Expression</th>
16
+
17
+ <th>Output</th>
18
+ </tr>
19
+ </thead>
20
+
21
+ <tr valign="top">
22
+ <td>d</td>
23
+
24
+ <td>the day as number without a leading zero (1 to 31)</td>
25
+ </tr>
26
+
27
+ <tr valign="top">
28
+ <td>dd</td>
29
+
30
+ <td>the day as number with a leading zero (01 to 31)</td>
31
+ </tr>
32
+
33
+ <tr valign="top">
34
+ <td>ddd</td>
35
+
36
+ <td>the abbreviated localized day name (e.g. 'Mon' to 'Sun'). Uses <a href=
37
+ "qdate.html#shortDayName">QDate::shortDayName</a>().</td>
38
+ </tr>
39
+
40
+ <tr valign="top">
41
+ <td>dddd</td>
42
+
43
+ <td>the long localized day name (e.g. 'Monday' to 'Sunday'). Uses <a href=
44
+ "qdate.html#longDayName">QDate::longDayName</a>().</td>
45
+ </tr>
46
+
47
+ <tr valign="top">
48
+ <td>M</td>
49
+
50
+ <td>the month as number without a leading zero (1-12)</td>
51
+ </tr>
52
+
53
+ <tr valign="top">
54
+ <td>MM</td>
55
+
56
+ <td>the month as number with a leading zero (01-12)</td>
57
+ </tr>
58
+
59
+ <tr valign="top">
60
+ <td>MMM</td>
61
+
62
+ <td>the abbreviated localized month name (e.g. 'Jan' to 'Dec'). Uses <a href=
63
+ "qdate.html#shortMonthName">QDate::shortMonthName</a>().</td>
64
+ </tr>
65
+
66
+ <tr valign="top">
67
+ <td>MMMM</td>
68
+
69
+ <td>the long localized month name (e.g. 'January' to 'December'). Uses <a href=
70
+ "qdate.html#longMonthName">QDate::longMonthName</a>().</td>
71
+ </tr>
72
+
73
+ <tr valign="top">
74
+ <td>yy</td>
75
+
76
+ <td>the year as two digit number (00-99)</td>
77
+ </tr>
78
+
79
+ <tr valign="top">
80
+ <td>yyyy</td>
81
+
82
+ <td>the year as four digit number</td>
83
+ </tr>
84
+ </table>
85
+
86
+ <p>These expressions may be used for the time part of the format string:</p>
87
+
88
+ <table>
89
+ <thead>
90
+ <tr>
91
+ <th>Expression</th>
92
+
93
+ <th>Output</th>
94
+ </tr>
95
+ </thead>
96
+
97
+ <tr valign="top">
98
+ <td>h</td>
99
+
100
+ <td>the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display)</td>
101
+ </tr>
102
+
103
+ <tr valign="top">
104
+ <td>hh</td>
105
+
106
+ <td>the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display)</td>
107
+ </tr>
108
+
109
+ <tr valign="top">
110
+ <td>H</td>
111
+
112
+ <td>the hour without a leading zero (0 to 23, even with AM/PM display)</td>
113
+ </tr>
114
+
115
+ <tr valign="top">
116
+ <td>HH</td>
117
+
118
+ <td>the hour with a leading zero (00 to 23, even with AM/PM display)</td>
119
+ </tr>
120
+
121
+ <tr valign="top">
122
+ <td>m</td>
123
+
124
+ <td>the minute without a leading zero (0 to 59)</td>
125
+ </tr>
126
+
127
+ <tr valign="top">
128
+ <td>mm</td>
129
+
130
+ <td>the minute with a leading zero (00 to 59)</td>
131
+ </tr>
132
+
133
+ <tr valign="top">
134
+ <td>s</td>
135
+
136
+ <td>the second without a leading zero (0 to 59)</td>
137
+ </tr>
138
+
139
+ <tr valign="top">
140
+ <td>ss</td>
141
+
142
+ <td>the second with a leading zero (00 to 59)</td>
143
+ </tr>
144
+
145
+ <tr valign="top">
146
+ <td>z</td>
147
+
148
+ <td>the milliseconds without leading zeroes (0 to 999)</td>
149
+ </tr>
150
+
151
+ <tr valign="top">
152
+ <td>zzz</td>
153
+
154
+ <td>the milliseconds with leading zeroes (000 to 999)</td>
155
+ </tr>
156
+
157
+ <tr valign="top">
158
+ <td>AP or A</td>
159
+
160
+ <td>interpret as an AM/PM time. <i>AP</i> must be either "AM" or "PM".</td>
161
+ </tr>
162
+
163
+ <tr valign="top">
164
+ <td>ap or a</td>
165
+
166
+ <td>Interpret as an AM/PM time. <i>ap</i> must be either "am" or "pm".</td>
167
+ </tr>
168
+ </table>
169
+
170
+ <br>
171
+
172
+ <h4>Example</h4>
173
+ <!-- Show example of function.-->
174
+ <code>format_date('2012-05-15','dd.mm.yyyy') → 15.00.2012</code><br>
0 commit comments