Ticket #7651: 7651.r8781.diff
File 7651.r8781.diff, 1.5 KB (added by , 16 years ago) |
---|
-
formatting.php
1208 1208 /** 1209 1209 * Converts an iso8601 date to MySQL DateTime format used by post_date[_gmt]. 1210 1210 * 1211 * {@internal Missing Long Description}}1212 *1213 1211 * @since 1.5.0 1214 1212 * 1215 1213 * @param string $date_string Date and time in ISO 8601 format {@link http://en.wikipedia.org/wiki/ISO_8601}. 1216 * @param unknown_type $timezone Optional. If set to GMT returns the time minus gmt_offset. Default USER.1214 * @param unknown_type $timezone Optional. If set to GMT returns the time minus gmt_offset. Default is 'user'. 1217 1215 * @return string The date and time in MySQL DateTime format - Y-m-d H:i:s. 1218 1216 */ 1219 function iso8601_to_datetime($date_string, $timezone = USER) {1220 if ($timezone == GMT) {1217 function iso8601_to_datetime($date_string, $timezone = 'user') { 1218 $timezone = strtolower($timezone); 1221 1219 1220 if ($timezone == 'gmt') { 1221 1222 1222 preg_match('#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\+|\-][0-9]{2,4}){0,1}#', $date_string, $date_bits); 1223 1223 1224 1224 if (!empty($date_bits[7])) { // we have a timezone, so let's compute an offset … … 1232 1232 1233 1233 return gmdate('Y-m-d H:i:s', $timestamp); 1234 1234 1235 } else if ($timezone == USER) {1235 } else if ($timezone == 'user') { 1236 1236 return preg_replace('#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\+|\-][0-9]{2,4}){0,1}#', '$1-$2-$3 $4:$5:$6', $date_string); 1237 1237 } 1238 1238 }