WordPress.org

Make WordPress Core

Ticket #16495: formatting.php.patch

File formatting.php.patch, 1.1 KB (added by chrisscott, 3 years ago)
  • wp-includes/formatting.php

     
    16781678 */ 
    16791679function iso8601_to_datetime($date_string, $timezone = 'user') { 
    16801680        $timezone = strtolower($timezone); 
     1681        $regex = '#([0-9]{4})-?([0-9]{2})-?([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:\.\d+)(Z|[\+|\-][0-9]{2,4}){0,1}#'; 
    16811682 
    16821683        if ($timezone == 'gmt') { 
    16831684 
    1684                 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); 
     1685                preg_match($regex, $date_string, $date_bits); 
    16851686 
    16861687                if (!empty($date_bits[7])) { // we have a timezone, so let's compute an offset 
    16871688                        $offset = iso8601_timezone_to_offset($date_bits[7]); 
     
    16951696                return gmdate('Y-m-d H:i:s', $timestamp); 
    16961697 
    16971698        } else if ($timezone == 'user') { 
    1698                 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); 
     1699                return preg_replace($regex, '$1-$2-$3 $4:$5:$6', $date_string); 
    16991700        } 
    17001701} 
    17011702