當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DateTimeUtils::GetDateTime方法代碼示例

本文整理匯總了PHP中DateTimeUtils::GetDateTime方法的典型用法代碼示例。如果您正苦於以下問題:PHP DateTimeUtils::GetDateTime方法的具體用法?PHP DateTimeUtils::GetDateTime怎麽用?PHP DateTimeUtils::GetDateTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DateTimeUtils的用法示例。


在下文中一共展示了DateTimeUtils::GetDateTime方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: date

    $lineItemService = $user->GetService('LineItemService', 'v201311');
    // Set the ID of the order to get line items from.
    $orderId = 'INSERT_ORDER_ID_HERE';
    // Calculate time from three days ago.
    $threeDaysAgo = date(DateTimeUtils::$DFP_DATE_TIME_STRING_FORMAT, strtotime('-3 day'));
    // Create bind variables.
    $vars = MapUtils::GetMapEntries(array('orderId' => new NumberValue($orderId), 'threeDaysAgo' => new TextValue($threeDaysAgo)));
    // Create statement object to only select line items belonging to the order
    // and have been modified in the last 3 days.
    $filterStatement = new Statement("WHERE orderId = :orderId " . "AND lastModifiedDateTime >= :threeDaysAgo " . "LIMIT 500", $vars);
    // Get line items by statement.
    $page = $lineItemService->getLineItemsByStatement($filterStatement);
    // Display results.
    if (isset($page->results)) {
        $i = $page->startIndex;
        foreach ($page->results as $lineItem) {
            // Format lastModifiedDateTime for printing.
            $lastModifiedDateTime = DateTimeUtils::GetDateTime($lineItem->lastModifiedDateTime);
            $lastModifiedDateTimeText = $lastModifiedDateTime->format(DateTimeUtils::$DFP_DATE_TIME_STRING_FORMAT);
            print $i . ') Line item with ID "' . $lineItem->id . '", belonging to order ID "' . $lineItem->orderId . '", with name "' . $lineItem->name . '", and last modified ' . $lastModifiedDateTimeText . " was found.\n";
            $i++;
        }
    }
    print 'Number of results found: ' . $page->totalResultSetSize . "\n";
} catch (OAuth2Exception $e) {
    ExampleUtils::CheckForOAuth2Errors($e);
} catch (ValidationException $e) {
    ExampleUtils::CheckForOAuth2Errors($e);
} catch (Exception $e) {
    print $e->getMessage() . "\n";
}
開發者ID:planetfitnessnational,項目名稱:googleads-php-lib,代碼行數:31,代碼來源:GetRecentlyUpdatedLineItems.php


注:本文中的DateTimeUtils::GetDateTime方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。