根据documentation, wc_memberships_get_user_memberships()
返回WC_Memberships_User_Membership
对象。
这个WC_Memberships_User_Membership
类具有get_end_date()
方法返回到期日期。
因此,您应该能够这样做:
// Get memberships for the current user.
$memberships = wc_memberships_get_user_memberships();
// Verify that they have some memberships.
if ( $memberships ) {
foreach( $memberships as $membership ) {
// Print the expiration date in mysql format.
echo $membership->get_end_date();
}
}
mysql日期格式是默认格式,但您也可以使用
$membership->get_end_date( \'Y-m-d H:i:s\' )
具有自定义格式或
$membership->get_end_date( \'timestamp\' )
获取时间戳。