diff --git wp-includes/functions.php wp-includes/functions.php
index abac7b5..009d510 100644
|
|
|
require( ABSPATH . WPINC . '/option.php' ); |
| 16 | 16 | * If $translate is true then the given date and format string will |
| 17 | 17 | * be passed to date_i18n() for translation. |
| 18 | 18 | * |
| | 19 | * if $gmt is true, ensure defalt_timezone is set to GMT/UTC so that the |
| | 20 | * results will correctly reflect the UTC timezone. |
| | 21 | * |
| 19 | 22 | * @since 0.71 |
| 20 | 23 | * |
| 21 | 24 | * @param string $format Format of the date to return. |
| 22 | 25 | * @param string $date Date string to convert. |
| 23 | 26 | * @param bool $translate Whether the return date should be translated. Default is true. |
| | 27 | * @param bool $gmt Return a date with UTC timezone. |
| 24 | 28 | * @return string|int Formatted date string, or Unix timestamp. |
| 25 | 29 | */ |
| 26 | | function mysql2date( $format, $date, $translate = true ) { |
| | 30 | function mysql2date( $format, $date, $translate = true, $gmt = false ) { |
| 27 | 31 | if ( empty( $date ) ) |
| 28 | 32 | return false; |
| 29 | 33 | |
| 30 | | if ( 'G' == $format ) |
| 31 | | return strtotime( $date . ' +0000' ); |
| | 34 | //If GMT is requested, ensure the correct timezone is set. |
| | 35 | if ( $gmt ) { |
| | 36 | //Store the current timezone so it can be restored when we're finished. |
| | 37 | $previous_tz = date_default_timezone_get(); |
| | 38 | date_default_timezone_set('UTC'); |
| | 39 | } |
| | 40 | |
| | 41 | /** |
| | 42 | * Store the new date in a variable. |
| | 43 | * We can't simply return it because we may have to restore the default timezone. |
| | 44 | * |
| | 45 | * Brackets used for clarity. |
| | 46 | */ |
| | 47 | if ( 'G' == $format ) { |
| | 48 | $new_date = strtotime( $date . ' +0000' ); |
| | 49 | } else { |
| | 50 | $i = strtotime( $date ); |
| | 51 | } |
| | 52 | |
| | 53 | if ( 'U' == $format ) { |
| | 54 | $new_date = $i; |
| | 55 | } else { |
| | 56 | //Add the "G != $format" statement so $new_date doesn't change if G really is the requested format. |
| | 57 | if ( ( 'G' != $format ) && ( $translate ) ) |
| | 58 | $new_date = date_i18n( $format, $i ); |
| 32 | 59 | |
| 33 | | $i = strtotime( $date ); |
| | 60 | elseif ( 'G' != $format ) |
| | 61 | $new_date = date( $format, $i ); |
| | 62 | } |
| 34 | 63 | |
| 35 | | if ( 'U' == $format ) |
| 36 | | return $i; |
| | 64 | //If needed, restore the original timezone. |
| | 65 | if ( $gmt ) |
| | 66 | date_default_timezone_set($previous_tz); |
| 37 | 67 | |
| 38 | | if ( $translate ) |
| 39 | | return date_i18n( $format, $i ); |
| 40 | | else |
| 41 | | return date( $format, $i ); |
| | 68 | return $new_date; |
| 42 | 69 | } |
| 43 | 70 | |
| 44 | 71 | /** |
diff --git wp-includes/general-template.php wp-includes/general-template.php
index faef3fa..29836ff 100644
|
|
|
function get_the_time( $d = '', $post = null ) { |
| 1498 | 1498 | * @return string |
| 1499 | 1499 | */ |
| 1500 | 1500 | function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false ) { // returns timestamp |
| 1501 | | $post = get_post($post); |
| | 1501 | $post = get_post( $post ); |
| 1502 | 1502 | |
| 1503 | 1503 | if ( $gmt ) |
| 1504 | 1504 | $time = $post->post_date_gmt; |
| 1505 | 1505 | else |
| 1506 | 1506 | $time = $post->post_date; |
| 1507 | 1507 | |
| 1508 | | $time = mysql2date($d, $time, $translate); |
| 1509 | | return apply_filters('get_post_time', $time, $d, $gmt); |
| | 1508 | $time = mysql2date( $d, $time, $translate, $gmt ); |
| | 1509 | return apply_filters( 'get_post_time', $time, $d, $gmt ); |
| 1510 | 1510 | } |
| 1511 | 1511 | |
| 1512 | 1512 | /** |
| … |
… |
function get_the_modified_time($d = '') { |
| 1548 | 1548 | * @return string Returns timestamp |
| 1549 | 1549 | */ |
| 1550 | 1550 | function get_post_modified_time( $d = 'U', $gmt = false, $post = null, $translate = false ) { |
| 1551 | | $post = get_post($post); |
| | 1551 | $post = get_post( $post ); |
| 1552 | 1552 | |
| 1553 | 1553 | if ( $gmt ) |
| 1554 | 1554 | $time = $post->post_modified_gmt; |
| 1555 | 1555 | else |
| 1556 | 1556 | $time = $post->post_modified; |
| 1557 | | $time = mysql2date($d, $time, $translate); |
| | 1557 | $time = mysql2date( $d, $time, $translate, $gmt ); |
| 1558 | 1558 | |
| 1559 | | return apply_filters('get_post_modified_time', $time, $d, $gmt); |
| | 1559 | return apply_filters( 'get_post_modified_time', $time, $d, $gmt ); |
| 1560 | 1560 | } |
| 1561 | 1561 | |
| 1562 | 1562 | /** |