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


PHP get_gmt_from_date函数代码示例

本文整理汇总了PHP中get_gmt_from_date函数的典型用法代码示例。如果您正苦于以下问题:PHP get_gmt_from_date函数的具体用法?PHP get_gmt_from_date怎么用?PHP get_gmt_from_date使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: test_get_gmt_from_date_during_dst

 /**
  * @ticket 20328
  */
 function test_get_gmt_from_date_during_dst()
 {
     update_option('timezone_string', 'Europe/London');
     $local = '2012-06-01 12:34:56';
     $gmt = '2012-06-01 11:34:56';
     $this->assertEquals($gmt, get_gmt_from_date($local));
 }
开发者ID:boonebgorges,项目名称:wp,代码行数:10,代码来源:date.php

示例2: update_orbis_task_meta

/**
 * Update Orbis task meta data
 *
 * @param array $data
 */
function update_orbis_task_meta($post_id, array $data = null)
{
    if (is_array($data)) {
        // Due At
        if (isset($data['_orbis_task_due_at_string'])) {
            $date_string = $data['_orbis_task_due_at_string'];
            $timestamp = strtotime($date_string);
            if ($timestamp !== false) {
                $date = date('Y-m-d H:i:s', $timestamp);
                $date_gmt = get_gmt_from_date($date);
                $data['_orbis_task_due_at'] = $date;
                $data['_orbis_task_due_at_gmt'] = $date_gmt;
            }
        }
        // Seconds
        if (isset($data['_orbis_task_seconds_string'])) {
            $data['_orbis_task_seconds'] = orbis_parse_time($data['_orbis_task_seconds_string']);
        }
        // Meta
        foreach ($data as $key => $value) {
            if ($value === '' || $value === null) {
                delete_post_meta($post_id, $key);
            } else {
                update_post_meta($post_id, $key, $value);
            }
        }
        // Sync
        orbis_save_task_sync($post_id);
    }
}
开发者ID:joffcrabtree,项目名称:wp-orbis-tasks,代码行数:35,代码来源:post.php

示例3: open

 public function open($email_id, $subscriber_id, $status = 1)
 {
     global $wpdb;
     // Initialise column format array
     $column_formats = $this->get_columns();
     $data = array('status' => $status, 'opened_count' => 1, 'opened_at' => get_gmt_from_date(date('Y-m-d H:i:s')));
     // Force fields to lower case
     $data = array_change_key_case($data);
     // White list columns
     $data = array_intersect_key($data, $column_formats);
     // Reorder $column_formats to match the order of columns given in $data
     $data_keys = array_keys($data);
     $column_formats = array_merge(array_flip($data_keys), $column_formats);
     if (false === ($rows = $wpdb->update($this->table_name, $data, array('email_id' => $email_id, 'subscriber_id' => $subscriber_id, 'status' => 0, 'opened_at' => '0000-00-00 00:00:00'), $column_formats))) {
         return false;
     }
     if ($rows === 0 && $status === 1) {
         $wpdb->query($wpdb->prepare(" Update " . $this->table_name . " set opened_count = opened_count+1 where email_id = %s and subscriber_id = %s ", $email_id, $subscriber_id));
     }
     if ($rows === 0 && $status > 1) {
         if (false === $wpdb->update($this->table_name, array('status' => $status), array('email_id' => $email_id, 'subscriber_id' => $subscriber_id))) {
             return false;
         }
     }
     return true;
 }
开发者ID:richardsweeney,项目名称:sendpress,代码行数:26,代码来源:class-sendpress-db-subscribers-tracker.php

示例4: upsert_post

 public function upsert_post($post, $silent = false)
 {
     global $wpdb;
     // reject the post if it's not a WP_Post
     if (!$post instanceof WP_Post) {
         return;
     }
     $post = $post->to_array();
     // reject posts without an ID
     if (!isset($post['ID'])) {
         return;
     }
     $now = current_time('mysql');
     $now_gmt = get_gmt_from_date($now);
     $defaults = array('ID' => 0, 'post_author' => '0', 'post_content' => '', 'post_content_filtered' => '', 'post_title' => '', 'post_name' => '', 'post_excerpt' => '', 'post_status' => 'draft', 'post_type' => 'post', 'comment_status' => 'closed', 'comment_count' => '0', 'ping_status' => '', 'post_password' => '', 'to_ping' => '', 'pinged' => '', 'post_parent' => 0, 'menu_order' => 0, 'guid' => '', 'post_date' => $now, 'post_date_gmt' => $now_gmt, 'post_modified' => $now, 'post_modified_gmt' => $now_gmt);
     $post = array_intersect_key($post, $defaults);
     $post = sanitize_post($post, 'db');
     unset($post['filter']);
     $exists = $wpdb->get_var($wpdb->prepare("SELECT EXISTS( SELECT 1 FROM {$wpdb->posts} WHERE ID = %d )", $post['ID']));
     if ($exists) {
         $wpdb->update($wpdb->posts, $post, array('ID' => $post['ID']));
     } else {
         $wpdb->insert($wpdb->posts, $post);
     }
     clean_post_cache($post['ID']);
 }
开发者ID:kanei,项目名称:vantuch.cz,代码行数:26,代码来源:class.jetpack-sync-wp-replicastore.php

示例5: eventon_create_duplicate_from_event

function eventon_create_duplicate_from_event($post, $parent = 0, $post_status = '')
{
    global $wpdb;
    $new_post_author = wp_get_current_user();
    $new_post_date = current_time('mysql');
    $new_post_date_gmt = get_gmt_from_date($new_post_date);
    if ($parent > 0) {
        $post_parent = $parent;
        $post_status = $post_status ? $post_status : 'publish';
        $suffix = '';
    } else {
        $post_parent = $post->post_parent;
        $post_status = $post_status ? $post_status : 'draft';
        $suffix = ' ' . __('(Copy)', 'eventon');
    }
    // Insert the new template in the post table
    $wpdb->insert($wpdb->posts, array('post_author' => $new_post_author->ID, 'post_date' => $new_post_date, 'post_date_gmt' => $new_post_date_gmt, 'post_content' => $post->post_content, 'post_content_filtered' => $post->post_content_filtered, 'post_title' => $post->post_title . $suffix, 'post_excerpt' => $post->post_excerpt, 'post_status' => $post_status, 'post_type' => $post->post_type, 'comment_status' => $post->comment_status, 'ping_status' => $post->ping_status, 'post_password' => $post->post_password, 'to_ping' => $post->to_ping, 'pinged' => $post->pinged, 'post_modified' => $new_post_date, 'post_modified_gmt' => $new_post_date_gmt, 'post_parent' => $post_parent, 'menu_order' => $post->menu_order, 'post_mime_type' => $post->post_mime_type));
    $new_post_id = $wpdb->insert_id;
    // Copy the taxonomies
    eventon_duplicate_post_taxonomies($post->ID, $new_post_id, $post->post_type);
    // Copy the meta information
    eventon_duplicate_post_meta($post->ID, $new_post_id);
    // ONLY for ticket addon event duplication
    if ($post->post_type == 'product') {
        $exclude = apply_filters('woocommerce_duplicate_product_exclude_children', false);
        if (!$exclude && ($children_products = get_children('post_parent=' . $post->ID . '&post_type=product_variation'))) {
            foreach ($children_products as $child) {
                eventon_create_duplicate_from_event(eventon_get_event_to_duplicate($child->ID), $new_post_id, $child->post_status);
            }
        }
    }
    return $new_post_id;
}
开发者ID:pab44,项目名称:pab44,代码行数:33,代码来源:duplicate_event.php

示例6: build_data

 /**
  * Compile the schema.org event data into an array
  */
 private function build_data()
 {
     global $post;
     $id = $post->ID;
     $events_data = array();
     // Index by ID: this will allow filter code to identify the actual event being referred to
     // without injecting an additional property
     $events_data[$id] = new stdClass();
     $events_data[$id]->{'@context'} = 'http://schema.org';
     $events_data[$id]->{'@type'} = 'Event';
     $events_data[$id]->name = get_the_title();
     if (has_post_thumbnail()) {
         $events_data[$id]->image = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
     }
     $events_data[$id]->url = get_the_permalink($post->ID);
     $events_data[$id]->startDate = get_gmt_from_date(tribe_get_start_date($post, true, TribeDateUtils::DBDATETIMEFORMAT), 'c');
     $events_data[$id]->endDate = get_gmt_from_date(tribe_get_end_date($post, true, TribeDateUtils::DBDATETIMEFORMAT), 'c');
     if (tribe_has_venue($id)) {
         $events_data[$id]->location = new stdClass();
         $events_data[$id]->location->{'@type'} = 'Place';
         $events_data[$id]->location->name = tribe_get_venue($post->ID);
         $events_data[$id]->location->address = strip_tags(str_replace("\n", '', tribe_get_full_address($post->ID)));
     }
     /**
      * Allows the event data to be modifed by themes and other plugins.
      *
      * @param array $events_data objects representing the Google Markup for each event.
      */
     $events_data = apply_filters('tribe_google_event_data', $events_data);
     // Strip the post ID indexing before returning
     $events_data = array_values($events_data);
     return $events_data;
 }
开发者ID:chicosilva,项目名称:olharambiental,代码行数:36,代码来源:Google_Data_Markup.php

示例7: clone_landing_page

 /**
  * Creates cloned landing page and opens it for user
  * @param string $status
  */
 public static function clone_landing_page($status = 'pending')
 {
     /* Get the original post */
     $id = isset($_GET['post']) ? $_GET['post'] : $_POST['post'];
     $post = get_post($id);
     /* Copy the post and insert it */
     if (!isset($post) || !$post) {
         $post_type_obj = get_post_type_object($post->post_type);
         wp_die(esc_attr(__('Copy creation failed, could not find original:', 'landing-pages')) . ' ' . $id);
     }
     if (!is_object($post) && is_numeric($post)) {
         $post = get_post($post);
     }
     $status = $post->post_status;
     /* We don't want to clone revisions */
     if ($post->post_type == 'revision') {
         return;
     }
     $prefix = "Copy of ";
     $suffix = "";
     $status = 'pending';
     $new_post_author = self::get_current_user();
     $new_post = array('menu_order' => $post->menu_order, 'comment_status' => $post->comment_status, 'ping_status' => $post->ping_status, 'post_author' => $new_post_author->ID, 'post_content' => $post->post_content, 'post_excerpt' => $post->post_excerpt, 'post_mime_type' => $post->post_mime_type, 'post_parent' => $new_post_parent = empty($parent_id) ? $post->post_parent : $parent_id, 'post_password' => $post->post_password, 'post_status' => $status, 'post_title' => $prefix . $post->post_title . $suffix, 'post_type' => $post->post_type);
     $new_post['post_date'] = $new_post_date = $post->post_date;
     $new_post['post_date_gmt'] = get_gmt_from_date($new_post_date);
     $new_post_id = wp_insert_post($new_post);
     $meta_data = self::get_meta($post->ID);
     foreach ($meta_data as $key => $value) {
         update_post_meta($new_post_id, $key, $value);
     }
     wp_redirect(admin_url('edit.php?post_type=' . $post->post_type));
     exit;
 }
开发者ID:gbaladi,项目名称:landing-pages,代码行数:37,代码来源:class.cloning.php

示例8: lp_duplicate_post_create_duplicate

function lp_duplicate_post_create_duplicate($post, $status = '', $parent_id = '', $blank = false)
{
    $prefix = "";
    $suffix = "";
    if (!is_object($post) && is_numeric($post)) {
        $post = get_post($post);
    }
    $status = $post->post_status;
    /* We don't want to clone revisions */
    if ($post->post_type == 'revision') {
        return;
    }
    if ($post->post_type != 'attachment') {
        $prefix = "Copy of ";
        $suffix = "";
        $status = 'pending';
    }
    $new_post_author = lp_duplicate_post_get_current_user();
    if ($blank == false) {
        $new_post = array('menu_order' => $post->menu_order, 'comment_status' => $post->comment_status, 'ping_status' => $post->ping_status, 'post_author' => $new_post_author->ID, 'post_content' => $post->post_content, 'post_excerpt' => $post->post_excerpt, 'post_mime_type' => $post->post_mime_type, 'post_parent' => $new_post_parent = empty($parent_id) ? $post->post_parent : $parent_id, 'post_password' => $post->post_password, 'post_status' => $status, 'post_title' => $prefix . $post->post_title . $suffix, 'post_type' => $post->post_type);
        $new_post['post_date'] = $new_post_date = $post->post_date;
        $new_post['post_date_gmt'] = get_gmt_from_date($new_post_date);
    } else {
        $new_post = array('menu_order' => $post->menu_order, 'comment_status' => $post->comment_status, 'ping_status' => $post->ping_status, 'post_author' => $new_post_author->ID, 'post_content' => "", 'post_excerpt' => "", 'post_mime_type' => $post->post_mime_type, 'post_status' => $status, 'post_title' => __("New Blank Landing Page", 'landing-pages'), 'post_type' => $post->post_type, 'post_date' => date('Y-m-d H:i:s'));
    }
    $new_post_id = wp_insert_post($new_post);
    $meta_data = lp_get_post_meta_all($post->ID);
    foreach ($meta_data as $key => $value) {
        update_post_meta($new_post_id, $key, $value);
    }
    return $new_post_id;
}
开发者ID:devilcranx,项目名称:landing-pages,代码行数:32,代码来源:module.clone.php

示例9: clonePage

 /**
  * Clones provided page ID
  * @param  int $pageId
  * @return int
  */
 public function clonePage($pageId)
 {
     $oldPost = get_post($pageId);
     if (null === $oldPost) {
         return 0;
     }
     if ('revision' === $oldPost->post_type) {
         return 0;
     }
     $currentUser = wp_get_current_user();
     $newPost = array('menu_order' => $oldPost->menu_order, 'comment_status' => $oldPost->comment_status, 'ping_status' => $oldPost->ping_status, 'post_author' => $currentUser->ID, 'post_content' => $oldPost->post_content, 'post_excerpt' => $oldPost->post_excerpt, 'post_mime_type' => $oldPost->post_mime_type, 'post_parent' => $oldPost->post_parent, 'post_password' => $oldPost->post_password, 'post_status' => $oldPost->post_status, 'post_title' => '(dup) ' . $oldPost->post_title, 'post_type' => $oldPost->post_type, 'post_date' => $oldPost->post_date, 'post_date_gmt' => get_gmt_from_date($oldPost->post_date));
     $newId = wp_insert_post($newPost);
     /*
      * Generating unique slug
      */
     if ($newPost['post_status'] == 'publish' || $newPost['post_status'] == 'future') {
         $postName = wp_unique_post_slug($oldPost->post_name, $newId, $newPost['post_status'], $oldPost->post_type, $newPost['post_parent']);
         $newPost = array();
         $newPost['ID'] = $newId;
         $newPost['post_name'] = $postName;
         wp_update_post($newPost);
     }
     $this->cloneMeta($pageId, $newId);
     $this->cloneOpData($pageId, $newId);
     return $newId;
 }
开发者ID:kyscastellanos,项目名称:arepa,代码行数:31,代码来源:clone_page.php

示例10: wowslider_add

function wowslider_add($folder = false, $update = 0, $delete = true)
{
    global $wp_filesystem, $wpdb, $user_ID;
    static $id = 0;
    if (!$folder) {
        return $id;
    }
    if (!$wp_filesystem || !is_object($wp_filesystem)) {
        WP_Filesystem();
    }
    if ($wp_filesystem->is_file($folder) && strtolower(substr($folder, -4)) == '.zip') {
        return wowslider_import($folder, $update, $delete);
    }
    $folder = rtrim(str_replace('\\', '/', $folder), '/') . '/';
    if ($wp_filesystem->is_file($folder . 'slider.html') && $wp_filesystem->is_dir($folder . 'images/')) {
        $images = array();
        $list = $wp_filesystem->dirlist($folder . ($wp_filesystem->is_dir($folder . 'tooltips/') ? 'tooltips/' : 'images/'));
        foreach ($list as $name => $v) {
            if ($v['type'] == 'f' && strtolower(substr($name, -4)) == '.jpg') {
                $images[] = $name;
            }
            if (count($images) == 10) {
                break;
            }
        }
        if (count($images)) {
            $name = '';
            if (preg_match('/<!--\\s*Name:(.+?)\\s*-->/ui', file_get_contents($folder . 'slider.html'), $match)) {
                $name = trim($match[1]);
            }
            $date = current_time('mysql');
            $insert = array('slider_name' => mb_substr($name, 0, 200), 'slider_author' => $user_ID, 'slider_date' => $date, 'slider_date_gmt' => get_gmt_from_date($date), 'slider_public' => 1, 'slider_images' => serialize($images));
            if ($update) {
                $insert['ID'] = $update;
            }
            foreach ($insert as $k => $v) {
                $insert[$k] = '"' . $wpdb->escape($v) . '"';
            }
            $wpdb->query('INSERT INTO ' . $wpdb->prefix . 'wowslider (' . implode(',', array_keys($insert)) . ') VALUES (' . implode(',', array_values($insert)) . ');');
            $id = $update ? (int) $update : (int) $wpdb->get_var('SELECT LAST_INSERT_ID();');
            if ($id) {
                $dest = WOWSLIDER_PLUGIN_PATH . 'sliders/' . $id . '/';
                if ($wp_filesystem->is_dir($dest)) {
                    $wp_filesystem->delete($dest, true);
                }
                $wp_filesystem->move($folder, $dest);
                if ($name == '') {
                    $wpdb->query('UPDATE ' . $wpdb->prefix . 'wowslider SET slider_name = "' . $wpdb->escape('Slider ' . $id) . '" WHERE ID = ' . $id . ';');
                }
                file_put_contents($dest . 'slider.html', str_replace('%ID%', $id, file_get_contents($dest . 'slider.html')));
                file_put_contents($dest . 'style.css', str_replace('%ID%', $id, file_get_contents($dest . 'style.css')));
                return true;
            } else {
                return __('Failure when added to the table.', 'wowslider');
            }
        }
    }
    return __('Wrong slider.', 'wowslider');
}
开发者ID:rmaloney,项目名称:simplewp_restaurant,代码行数:59,代码来源:api.php

示例11: duplicate_post

 function duplicate_post($old_id)
 {
     global $wpdb, $table_prefix;
     $sql = sprintf("select * from %sposts where ID = %s", $table_prefix, $old_id);
     $old_post = $wpdb->get_row($sql);
     $sql = sprintf("select * from %spostmeta where post_id = %s", $table_prefix, $old_id);
     $old_meta = $wpdb->get_results($sql);
     $sql = sprintf("select * from %sterm_relationships where object_id = %s", $table_prefix, $old_id);
     $old_term = $wpdb->get_results($sql);
     if (defined('STARRATING_INSTALLED')) {
         $sql = sprintf("select * from %sgdsr_data_article where post_id = %s", $table_prefix, $old_id);
         $old_gdsr = $wpdb->get_row($sql);
     }
     $post_date = current_time('mysql');
     $post_date_gmt = get_gmt_from_date($post_date);
     unset($old_post->ID);
     unset($old_post->filter);
     unset($old_post->guid);
     unset($old_post->post_date_gmt);
     $old_post->post_date = $post_date;
     $old_post->post_status = "draft";
     $old_post->post_title .= " (1)";
     $old_post->post_name .= "-1";
     $old_post->post_modified = $post_date;
     $old_post->post_modified_gmt = $post_date_gmt;
     $old_post->comment_count = "0";
     if (false === $wpdb->insert($wpdb->posts, get_object_vars($old_post))) {
         return 0;
     }
     $post_ID = (int) $wpdb->insert_id;
     $wpdb->update($wpdb->posts, array('guid' => get_permalink($post_ID)), array('ID' => $post_ID));
     foreach ($old_meta as $m) {
         unset($m->meta_id);
         $m->post_id = $post_ID;
         $wpdb->insert($wpdb->postmeta, get_object_vars($m));
     }
     foreach ($old_term as $m) {
         unset($m->meta_id);
         $m->object_id = $post_ID;
         $wpdb->insert($wpdb->term_relationships, get_object_vars($m));
     }
     if (is_object($old_gdsr)) {
         $old_gdsr->post_id = $post_ID;
         unset($old_gdsr->user_voters);
         unset($old_gdsr->user_votes);
         unset($old_gdsr->visitor_voters);
         unset($old_gdsr->visitor_votes);
         unset($old_gdsr->review);
         unset($old_gdsr->views);
         unset($old_gdsr->user_recc_plus);
         unset($old_gdsr->user_recc_minus);
         unset($old_gdsr->visitor_recc_plus);
         unset($old_gdsr->visitor_recc_minus);
         unset($old_gdsr->last_voted);
         unset($old_gdsr->last_voted_recc);
         $wpdb->insert($table_prefix . "gdsr_data_article", get_object_vars($old_gdsr));
     }
     return $post_ID;
 }
开发者ID:hewu,项目名称:blogwp,代码行数:59,代码来源:db.php

示例12: fyd_create_results_page

 /**
  * Create a new page to display the search results.
  * This page will essentially be the home of the app, 
  * and the one to which we inject all the information 
  * the app displays.
  *
  */
 private static function fyd_create_results_page()
 {
     $date = get_the_date('Y-m-d H:i:s');
     $page_template_path = plugins_url('/templates/page-find-your-do-results.php', __FILE__);
     $args = array('post_content' => '', 'post_title' => 'Find Your DO Results', 'post_status' => 'publish', 'post_type' => 'page', 'ping_status' => 'closed', 'post_date' => $date, 'post_date_gmt' => get_gmt_from_date($date), 'comment_status' => 'closed');
     $post_id = wp_insert_post($args);
     return $post_id;
 }
开发者ID:pjsinco,项目名称:find-your-do-play,代码行数:15,代码来源:class-find-your-do-activator.php

示例13: pronamic_events_get_end_date_meta

function pronamic_events_get_end_date_meta($timestamp, array &$meta = array())
{
    $date = date('Y-m-d H:i:s', $timestamp);
    $date_gmt = get_gmt_from_date($date);
    $meta['_pronamic_end_date'] = $timestamp;
    $meta['_pronamic_event_end_date'] = $date;
    $meta['_pronamic_event_end_date_gmt'] = $date_gmt;
    return $meta;
}
开发者ID:joffcrabtree,项目名称:wp-pronamic-events,代码行数:9,代码来源:functions.php

示例14: test_date

 function test_date()
 {
     $this->make_user_by_role('editor');
     $result = $this->myxmlrpcserver->wp_getPage(array(1, $this->post_id, 'editor', 'editor'));
     $this->assertNotInstanceOf('IXR_Error', $result);
     $this->assertInstanceOf('IXR_Date', $result['dateCreated']);
     $this->assertInstanceOf('IXR_Date', $result['date_created_gmt']);
     $date_gmt = strtotime(get_gmt_from_date(mysql2date('Y-m-d H:i:s', $this->post_data['post_date'], false), 'Ymd\\TH:i:s'));
     $this->assertEquals($this->post_date_ts, $result['dateCreated']->getTimestamp());
     $this->assertEquals($date_gmt, $result['date_created_gmt']->getTimestamp());
 }
开发者ID:boonebgorges,项目名称:develop.wordpress,代码行数:11,代码来源:getPage.php

示例15: comment

 function comment($id, $post_id, $props = array())
 {
     global $wp_version;
     $now = current_time('mysql');
     $now_gmt = get_gmt_from_date($now);
     $comment = (object) array_merge(self::$default_comment_props, $props, array('comment_ID' => $id, 'comment_post_ID' => $post_id, 'comment_date' => $now, 'comment_date_gmt' => $now_gmt));
     if (version_compare($wp_version, '4.4', '<')) {
         return $comment;
     }
     return new WP_Comment($comment);
 }
开发者ID:iamtakashi,项目名称:jetpack,代码行数:11,代码来源:class.jetpack-sync-test-object-factory.php


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