当前位置: 首页>>代码示例>>PHP>>正文


PHP DateHelper::u2s方法代码示例

本文整理汇总了PHP中DateHelper::u2s方法的典型用法代码示例。如果您正苦于以下问题:PHP DateHelper::u2s方法的具体用法?PHP DateHelper::u2s怎么用?PHP DateHelper::u2s使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DateHelper的用法示例。


在下文中一共展示了DateHelper::u2s方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: for_from_until

 /**
  * Adjust from und until dates from UTZ to STZ and take into account the
  * for option which will adjust the from date to that of the current
  * day, the start of the week or the month, leaving the until date
  * set to null.
  * 
  * @param string $for "day", "week" or "month"
  * @param string $from date/datetime
  * @param string $until date/datetime
  */
 private static function for_from_until($for, &$from, &$until)
 {
     include_once AFFILIATES_CORE_LIB . '/class-affiliates-date-helper.php';
     if ($for === null) {
         if ($from !== null) {
             $from = date('Y-m-d H:i:s', strtotime(DateHelper::u2s($from)));
         }
         if ($until !== null) {
             $until = date('Y-m-d H:i:s', strtotime(DateHelper::u2s($until)));
         }
     } else {
         $user_now = strtotime(DateHelper::s2u(date('Y-m-d H:i:s', time())));
         $user_now_datetime = date('Y-m-d H:i:s', $user_now);
         $user_daystart_datetime = date('Y-m-d', $user_now) . ' 00:00:00';
         $server_now_datetime = DateHelper::u2s($user_now_datetime);
         $server_user_daystart_datetime = DateHelper::u2s($user_daystart_datetime);
         $until = null;
         switch (strtolower($for)) {
             case 'day':
                 $from = date('Y-m-d H:i:s', strtotime($server_user_daystart_datetime));
                 break;
             case 'week':
                 $fdow = intval(get_option('start_of_week'));
                 $dow = intval(date('w', strtotime($server_user_daystart_datetime)));
                 $d = $dow - $fdow;
                 $from = date('Y-m-d H:i:s', mktime(0, 0, 0, date('m', strtotime($server_user_daystart_datetime)), date('d', strtotime($server_user_daystart_datetime)) - $d, date('Y', strtotime($server_user_daystart_datetime))));
                 break;
             case 'month':
                 $from = date('Y-m', strtotime($server_user_daystart_datetime)) . '-01 00:00:00';
                 break;
             default:
                 $from = null;
         }
     }
 }
开发者ID:mahassan,项目名称:shellneverknow,代码行数:45,代码来源:class-affiliates-shortcodes.php

示例2: affiliates_admin_hits


//.........这里部分代码省略.........
    }
    $orderby = isset($_GET['orderby']) ? $_GET['orderby'] : null;
    switch ($orderby) {
        case 'date':
        case 'visits':
        case 'hits':
        case 'referrals':
        case 'ratio':
            break;
        case 'affiliate_id':
            $orderby = 'name';
        default:
            $orderby = 'date';
    }
    $order = isset($_GET['order']) ? $_GET['order'] : null;
    switch ($order) {
        case 'asc':
        case 'ASC':
            $switch_order = 'DESC';
            break;
        case 'desc':
        case 'DESC':
            $switch_order = 'ASC';
            break;
        default:
            $order = 'DESC';
            $switch_order = 'ASC';
    }
    $filters = " WHERE 1=%d ";
    $filter_params = array(1);
    // We now have the desired dates from the user's point of view, i.e. in her timezone.
    // If supported, adjust the dates for the site's timezone:
    if ($from_date) {
        $from_datetime = DateHelper::u2s($from_date);
    }
    if ($thru_date) {
        $thru_datetime = DateHelper::u2s($thru_date, 24 * 3600);
    }
    if ($from_date && $thru_date) {
        $filters .= " AND datetime >= %s AND datetime < %s ";
        $filter_params[] = $from_datetime;
        $filter_params[] = $thru_datetime;
    } else {
        if ($from_date) {
            $filters .= " AND datetime >= %s ";
            $filter_params[] = $from_datetime;
        } else {
            if ($thru_date) {
                $filters .= " AND datetime < %s ";
                $filter_params[] = $thru_datetime;
            }
        }
    }
    if ($affiliate_id) {
        $filters .= " AND affiliate_id = %d ";
        $filter_params[] = $affiliate_id;
    }
    // how many are there ?
    $count_query = $wpdb->prepare("SELECT date FROM {$hits_table} h\n\t\t{$filters}\n\t\tGROUP BY date\n\t\t", $filter_params);
    $wpdb->query($count_query);
    $count = $wpdb->num_rows;
    if ($count > $row_count) {
        $paginate = true;
    } else {
        $paginate = false;
    }
开发者ID:FelipeCastello,项目名称:affiliates,代码行数:67,代码来源:affiliates-admin-hits.php

示例3: affiliates_admin_affiliates


//.........这里部分代码省略.........
                }
            } else {
                $affiliate_user_login = null;
                $affiliates_options->delete_option('affiliates_affiliate_user_login');
            }
            $show_deleted = isset($_POST['show_deleted']);
            $affiliates_options->update_option('affiliates_show_deleted', $show_deleted);
            $show_inoperative = isset($_POST['show_inoperative']);
            $affiliates_options->update_option('affiliates_show_inoperative', $show_inoperative);
            // filter by date(s)
            if (!empty($_POST['from_date'])) {
                $from_date = date('Y-m-d', strtotime($_POST['from_date']));
                $affiliates_options->update_option('affiliates_from_date', $from_date);
            } else {
                $from_date = null;
                $affiliates_options->delete_option('affiliates_from_date');
            }
            if (!empty($_POST['thru_date'])) {
                $thru_date = date('Y-m-d', strtotime($_POST['thru_date']));
                $affiliates_options->update_option('affiliates_thru_date', $thru_date);
            } else {
                $thru_date = null;
                $affiliates_options->delete_option('affiliates_thru_date');
            }
            if ($from_date && $thru_date) {
                if (strtotime($from_date) > strtotime($thru_date)) {
                    $thru_date = null;
                    $affiliates_options->delete_option('affiliates_thru_date');
                }
            }
            // We now have the desired dates from the user's point of view, i.e. in her timezone.
            // If supported, adjust the dates for the site's timezone:
            if ($from_date) {
                $from_datetime = DateHelper::u2s($from_date);
            }
            if ($thru_date) {
                $thru_datetime = DateHelper::u2s($thru_date, 24 * 3600);
            }
            // filter by affiliate id
            if (!empty($_POST['affiliate_id'])) {
                $affiliate_id = affiliates_check_affiliate_id($_POST['affiliate_id']);
                if ($affiliate_id) {
                    $affiliates_options->update_option('affiliates_affiliate_id', $affiliate_id);
                }
            } else {
                if (isset($_POST['affiliate_id'])) {
                    // empty && isset => '' => all
                    $affiliate_id = null;
                    $affiliates_options->delete_option('affiliates_affiliate_id');
                }
            }
        }
    }
    if (isset($_POST['row_count'])) {
        if (!wp_verify_nonce($_POST[AFFILIATES_ADMIN_AFFILIATES_NONCE_1], 'admin')) {
            wp_die(__('Access denied.', AFFILIATES_PLUGIN_DOMAIN));
        }
    }
    if (isset($_POST['paged'])) {
        if (!wp_verify_nonce($_POST[AFFILIATES_ADMIN_AFFILIATES_NONCE_2], 'admin')) {
            wp_die(__('Access denied.', AFFILIATES_PLUGIN_DOMAIN));
        }
    }
    $current_url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    $current_url = remove_query_arg('paged', $current_url);
    $current_url = remove_query_arg('action', $current_url);
开发者ID:mahassan,项目名称:shellneverknow,代码行数:67,代码来源:affiliates-admin-affiliates.php

示例4: affiliates_admin_hits_affiliate


//.........这里部分代码省略.........
        $paged = 0;
    }
    $orderby = isset($_GET['orderby']) ? $_GET['orderby'] : null;
    switch ($orderby) {
        case 'date':
        case 'visits':
        case 'hits':
        case 'referrals':
        case 'ratio':
        case 'name':
            break;
        default:
            $orderby = 'name';
    }
    $order = isset($_GET['order']) ? $_GET['order'] : null;
    switch ($order) {
        case 'asc':
        case 'ASC':
            $switch_order = 'DESC';
            break;
        case 'desc':
        case 'DESC':
            $switch_order = 'ASC';
            break;
        default:
            $order = 'ASC';
            $switch_order = 'DESC';
    }
    $filters = " WHERE 1=%d ";
    $filter_params = array(1);
    // We now have the desired dates from the user's point of view, i.e. in her timezone.
    // If supported, adjust the dates for the site's timezone:
    if ($from_date) {
        $from_datetime = DateHelper::u2s($from_date);
    }
    if ($thru_date) {
        $thru_datetime = DateHelper::u2s($thru_date, 24 * 3600);
    }
    if ($from_date && $thru_date) {
        $filters .= " AND datetime >= %s AND datetime < %s ";
        $filter_params[] = $from_datetime;
        $filter_params[] = $thru_datetime;
    } else {
        if ($from_date) {
            $filters .= " AND datetime >= %s ";
            $filter_params[] = $from_datetime;
        } else {
            if ($thru_date) {
                $filters .= " AND datetime < %s ";
                $filter_params[] = $thru_datetime;
            }
        }
    }
    if ($affiliate_id) {
        $filters .= " AND h.affiliate_id = %d ";
        $filter_params[] = $affiliate_id;
    }
    // how many are there ?
    $count_query = $wpdb->prepare("SELECT affiliate_id FROM {$hits_table} h\n\t\t{$filters}\n\t\tGROUP BY affiliate_id\n\t\t", $filter_params);
    $wpdb->query($count_query);
    $count = $wpdb->num_rows;
    if ($count > $row_count) {
        $paginate = true;
    } else {
        $paginate = false;
    }
开发者ID:FelipeCastello,项目名称:affiliates,代码行数:67,代码来源:affiliates-admin-hits-affiliate.php

示例5: update_status

 public static function update_status($new_status, $params = null)
 {
     global $wpdb;
     $output = "";
     $from_date = isset($params['from_date']) ? $params['from_date'] : null;
     $from_datetime = $from_date ? DateHelper::u2s($from_date) : null;
     $thru_date = isset($params['thru_date']) ? $params['thru_date'] : null;
     $thru_datetime = $thru_date ? DateHelper::u2s($thru_date, 24 * 3600) : null;
     $referral_status = isset($params['referral_status']) ? Affiliates_Utility::verify_referral_status_transition($params['referral_status'], $params['referral_status']) : null;
     $currency_id = isset($params['currency_id']) ? Affiliates_Utility::verify_currency_id($params['currency_id']) : null;
     $orderby = isset($params['orderby']) ? $params['orderby'] : null;
     $order = isset($params['order']) ? $params['order'] : null;
     switch ($orderby) {
         case 'affiliate_id':
         case 'name':
         case 'email':
             $orderby = 'a.' . $orderby;
             break;
         case 'user_login':
             $orderby = 'au.' . $orderby;
             break;
         case 'currency_id':
             $orderby = 'r.' . $orderby;
             break;
         default:
             $orderby = 'a.name';
     }
     switch ($order) {
         case 'asc':
         case 'ASC':
         case 'desc':
         case 'DESC':
             break;
         default:
             $order = 'ASC';
     }
     if (isset($params['tables'])) {
         $output .= "<h1>" . __("Closing referrals", AFFILIATES_PLUGIN_DOMAIN) . "</h1>";
         $output .= "<div class='closing-referrals-overview'>";
         $affiliates_table = $params['tables']['affiliates'];
         $affiliates_users_table = $params['tables']['affiliates_users'];
         $referrals_table = $params['tables']['referrals'];
         $users_table = $params['tables']['users'];
         $filters = array(" 1=%d ");
         $filter_params = array(1);
         if ($from_datetime && $thru_datetime) {
             $filters[] = " r.datetime >= %s AND r.datetime < %s ";
             $filter_params[] = $from_datetime;
             $filter_params[] = $thru_datetime;
         } else {
             if ($from_datetime) {
                 $filters[] = " r.datetime >= %s ";
                 $filter_params[] = $from_datetime;
             } else {
                 if ($thru_datetime) {
                     $filters[] = " r.datetime < %s ";
                     $filter_params[] = $thru_datetime;
                 }
             }
         }
         if ($referral_status) {
             $filters[] = " r.status = %s ";
             $filter_params[] = $referral_status;
         }
         if ($currency_id) {
             $filters[] = " r.currency_id = %s ";
             $filter_params[] = $currency_id;
         }
         if (!empty($filters)) {
             $filters = " WHERE " . implode(" AND ", $filters);
         } else {
             $filters = '';
         }
         $order_by = '';
         if ($orderby && $order) {
             $order_by .= " ORDER BY {$orderby} {$order} ";
         }
         $step = isset($params['step']) ? intval($params['step']) : 1;
         switch ($step) {
             case 1:
                 $results = $wpdb->get_results($wpdb->prepare("\n\t\t\t\t\t\tSELECT a.*, r.*, u.user_login\n\t\t\t\t\t\tFROM {$referrals_table} r\n\t\t\t\t\t\tLEFT JOIN {$affiliates_table} a ON r.affiliate_id = a.affiliate_id\n\t\t\t\t\t\tLEFT JOIN {$affiliates_users_table} au ON a.affiliate_id = au.affiliate_id\n\t\t\t\t\t\tLEFT JOIN {$users_table} u on au.user_id = u.ID\n\t\t\t\t\t\t{$filters}\n\t\t\t\t\t\t{$order_by}\n\t\t\t\t\t\t", $filter_params));
                 $output .= "<div class='manage'>";
                 $output .= "<div class='warning'>";
                 $output .= "<p>";
                 $output .= "<strong>";
                 $output .= __("Please review the list of referrals that will be <em>closed</em>.", AFFILIATES_PLUGIN_DOMAIN);
                 $output .= "</strong>";
                 $output .= "</p>";
                 $output .= "</div>";
                 // .warning
                 $output .= "<p>";
                 $output .= __("Usually only referrals that are <em>accepted</em> and have been paid out should be <em>closed</em>. If there are unwanted or too many referrals shown, restrict your filter settings.", AFFILIATES_PLUGIN_DOMAIN);
                 $output .= "</p>";
                 $output .= "<p>";
                 $output .= __("If these referrals can be closed, click the confirmation button below.", AFFILIATES_PLUGIN_DOMAIN);
                 $output .= "</p>";
                 $output .= "</div>";
                 $output .= '<div id="referrals-overview" class="referrals-overview">';
                 $output .= self::render_results($results);
                 $output .= '</div>';
//.........这里部分代码省略.........
开发者ID:FelipeCastello,项目名称:affiliates,代码行数:101,代码来源:class-affiliates-totals.php

示例6: affiliates_admin_referrals


//.........这里部分代码省略.........
        case 'datetime':
        case 'name':
        case 'post_title':
        case 'amount':
        case 'currency_id':
        case 'status':
            break;
        default:
            $orderby = 'datetime';
    }
    $order = isset($_GET['order']) ? $_GET['order'] : null;
    switch ($order) {
        case 'asc':
        case 'ASC':
            $switch_order = 'DESC';
            break;
        case 'desc':
        case 'DESC':
            $switch_order = 'ASC';
            break;
        default:
            $order = 'DESC';
            $switch_order = 'ASC';
    }
    if ($from_date || $thru_date || $affiliate_id || $status || $search) {
        $filters = " WHERE ";
    } else {
        $filters = '';
    }
    $filter_params = array();
    // We have the desired dates from the user's point of view, i.e. in her timezone.
    // If supported, adjust the dates for the site's timezone:
    if ($from_date) {
        $from_datetime = DateHelper::u2s($from_date);
    }
    if ($thru_date) {
        $thru_datetime = DateHelper::u2s($thru_date, 24 * 3600);
    }
    if ($from_date && $thru_date) {
        $filters .= " datetime >= %s AND datetime < %s ";
        $filter_params[] = $from_datetime;
        $filter_params[] = $thru_datetime;
    } else {
        if ($from_date) {
            $filters .= " datetime >= %s ";
            $filter_params[] = $from_datetime;
        } else {
            if ($thru_date) {
                $filters .= " datetime < %s ";
                $filter_params[] = $thru_datetime;
            }
        }
    }
    if ($affiliate_id) {
        if ($from_date || $thru_date) {
            $filters .= " AND ";
        }
        $filters .= " r.affiliate_id = %d ";
        $filter_params[] = $affiliate_id;
    }
    if ($status) {
        if ($from_date || $thru_date || $affiliate_id) {
            $filters .= " AND ";
        }
        $filters .= " r.status = %s ";
        $filter_params[] = $status;
开发者ID:mahassan,项目名称:shellneverknow,代码行数:67,代码来源:affiliates-admin-referrals.php


注:本文中的DateHelper::u2s方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。