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