本文整理汇总了PHP中EE_Transaction::get_DateTime_object方法的典型用法代码示例。如果您正苦于以下问题:PHP EE_Transaction::get_DateTime_object方法的具体用法?PHP EE_Transaction::get_DateTime_object怎么用?PHP EE_Transaction::get_DateTime_object使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EE_Transaction
的用法示例。
在下文中一共展示了EE_Transaction::get_DateTime_object方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _get_payment_due_date
/**
* Parser for the [PAYMENT_DUE_DATE_*] attribute type shortcode
*
* @since 4.8.28.rc.011
*
* @param string $shortcode The shortcode being parsed.
* @param EE_Transaction $transaction
* @return string
*/
protected function _get_payment_due_date($shortcode, EE_Transaction $transaction)
{
//if transaction is paid in full then we can just return an empty string
if ($transaction->remaining() === 0) {
return '';
}
$attrs = $this->_get_shortcode_attrs($shortcode);
$format = isset($attrs['format']) ? $attrs['format'] : get_option('date_format');
$days_until_due = isset($attrs['days_until_due']) ? (int) $attrs['days_until_due'] : 30;
$prefix_text = isset($attrs['prefix_text']) ? $attrs['prefix_text'] : __('Payment in full due by: ', 'event_espresso');
$transaction_created = $transaction->get_DateTime_object('TXN_timestamp');
//setup date due:
try {
if ($transaction_created instanceof DateTime) {
$date_due = $transaction_created->add(new DateInterval('P' . $days_until_due . 'D'))->format($format);
} else {
throw new Exception();
}
} catch (Exception $e) {
//format was likely invalid.
$date_due = 'Unable to calculate date due, likely the format string is invalid.';
}
return $prefix_text . $date_due;
}