تابع wc_rest_prepare_date_response تجزیه و فرمت تاریخ با استاندارد ISO8601
تابع wc_rest_prepare_date_response – تجزیه و فرمت تاریخ با استاندارد ISO8601
Syntax – سینتکس
(string|null) wc_rest_prepare_date_response( (string|null|WC_DateTime) $date, (bool) $utc = true );
Parameters – پارامتر ها (2)
- 1- $date (string|null|WC_DateTime)
- 2- $utc (bool)
Returns – مقادیر بازگشتی (string|null)
ISO8601/RFC3339 formatted datetime.
Usage – نحوه استفاده
if ( !function_exists( 'wc_rest_prepare_date_response' ) ) { require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-rest-functions.php'; } // The date. $date = null; // Send false to get local/offset time. $utc = true; // NOTICE! Understand what this does before running. $result = wc_rest_prepare_date_response($date, $utc);
Defined – محل تعریف
/includes/wc-rest-functions.php
function wc_rest_prepare_date_response( $date, $utc = true ) { if ( is_numeric( $date ) ) { $date = new WC_DateTime( "@$date", new DateTimeZone( 'UTC' ) ); $date->setTimezone( new DateTimeZone( wc_timezone_string() ) ); } elseif ( is_string( $date ) ) { $date = new WC_DateTime( $date, new DateTimeZone( 'UTC' ) ); $date->setTimezone( new DateTimeZone( wc_timezone_string() ) ); } if ( ! is_a( $date, 'WC_DateTime' ) ) { return null; } // Get timestamp before changing timezone to UTC. return gmdate( 'Y-m-d\TH:i:s', $utc ? $date->getTimestamp() : $date->getOffsetTimestamp() ); }
versions – نسخه ها
از نسخه : 2.6.0
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر