本文整理汇总了PHP中get_date_from_gmt函数的典型用法代码示例。如果您正苦于以下问题:PHP get_date_from_gmt函数的具体用法?PHP get_date_from_gmt怎么用?PHP get_date_from_gmt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_date_from_gmt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Create export file with data
*/
public function create()
{
$sheet_id = !empty($_GET['sheet_id']) ? $_GET['sheet_id'] : null;
$data = $this->data->get_all_data($sheet_id);
header("Content-type: text/csv");
header("Content-Disposition: attachment; filename=sign-up-sheets-" . date('Ymd-His') . ".csv");
header("Pragma: no-cache");
header("Expires: 0");
$all_custom_fields = get_option('dls_sus_custom_fields');
if (!empty($all_custom_fields)) {
$custom_field_names = array();
foreach ($all_custom_fields as $field) {
$custom_field_names[] = $field['name'];
}
reset($all_custom_fields);
}
$custom_fields_heading = !empty($custom_field_names) ? '"' . implode('","', $custom_field_names) . '",' : null;
$csv = '"Sheet ID","Sheet Title","Sheet Date","Task ID","Task Title","Task Date","Sign-up ID","Sign-up First Name","Sign-up Last Name","Sign-up Phone","Sign-up Email",' . $custom_fields_heading . '"Reminded"' . "\n";
foreach ($data as $d) {
$csv .= '"' . $this->clean_csv($d->sheet_id) . '","' . $this->clean_csv($d->sheet_title) . '","' . $this->clean_csv(!empty($d->sheet_date) && $d->sheet_date !== '0000-00-00' ? date('Y-m-d', strtotime($d->sheet_date)) : null) . '","' . $this->clean_csv($d->task_id) . '","' . $this->clean_csv($d->task_title) . '","' . $this->clean_csv(!empty($d->task_date) && $d->task_date !== '0000-00-00' ? date('Y-m-d', strtotime($d->task_date)) : null) . '","' . $this->clean_csv($d->signup_id) . '","' . $this->clean_csv($d->firstname) . '","' . $this->clean_csv($d->lastname) . '","' . $this->clean_csv($d->phone) . '","' . $this->clean_csv($d->email) . '","';
if (!empty($all_custom_fields)) {
foreach ($all_custom_fields as $field) {
$slug = str_replace('-', '_', $field['slug']);
if (!isset($d->signup_fields[$slug])) {
$d->signup_fields[$slug] = '';
}
$csv .= $this->clean_csv(is_array($d->signup_fields[$slug]) ? implode(', ', $d->signup_fields[$slug]) : $d->signup_fields[$slug]) . '","';
}
}
$csv .= $this->clean_csv(!empty($d->reminded) ? get_date_from_gmt($d->reminded, 'Y-m-d H:i:s') : null) . '"' . "\n";
}
echo $csv;
}
示例2: rssmi_show_last_feed_update
/**
* Displays the last time the feed was updated and controls to update now
*
* @return string
*/
function rssmi_show_last_feed_update()
{
$wprssmi_admin_options = get_option('rss_admin_options');
// admin settings
$last_db_update = $wprssmi_admin_options['last_db_update'];
return "\n\t<h3>Last Update of the Feed Database: <em>" . get_date_from_gmt(date('Y-m-d H:i:s', $last_db_update), 'M j, Y @ g:i a') . "; " . human_time_diff($last_db_update, time()) . " ago</em></h3>\n\t<p><button type='button' name='getFeedsNow' id='getFeeds-Now' class='button button-primary' value=''>Update the feed Database</button></p>\n\n\t<div id='gfnote'>\n\t\t<em>(note: this could take several minutes)</em>\n\t</div>\n\t<div id='rssmi-ajax-loader-center'></div>\n\t<p>Think there is a scheduling problem? <a href='http://www.wprssimporter.com/faqs/the-cron-scheduler-isnt-working-whats-happening/' target='_blank'>Read this</a>.</p>";
}
示例3: format_date_time_gmt
public function format_date_time_gmt($timestamp_gmt)
{
$f = get_option('date_format') . ' ' . get_option('time_format');
$s = gmdate('Y-m-d H:i:s', $timestamp_gmt);
$s = get_date_from_gmt($s, $f);
return $s;
}
示例4: prepare_items
public function prepare_items()
{
if (!is_null($this->total_items)) {
return;
}
$this->total_items = count($this->_archives);
$this->set_pagination_args(array('total_items' => $this->total_items, 'per_page' => $this->items_pre_page));
/**
* @var FW_Extension_Backups $backups
*/
$backups = fw_ext('backups');
/**
* Prepare items for output
*/
foreach ($this->_archives as $filename => $archive) {
$time = get_date_from_gmt(gmdate('Y-m-d H:i:s', $archive['time']), get_option('date_format') . ' ' . get_option('time_format'));
$filename_hash = md5($filename);
$details = array();
$details[] = $archive['full'] ? __('Full Backup', 'fw') : __('Content Backup', 'fw');
if (function_exists('fw_human_bytes')) {
$details[] = fw_human_bytes(filesize($archive['path']));
}
$details[] = fw_html_tag('a', array('href' => $backups->get_download_link($filename), 'target' => '_blank', 'id' => 'download-' . $filename_hash, 'data-download-file' => $filename), esc_html__('Download', 'fw'));
$details[] = fw_html_tag('a', array('href' => '#', 'onclick' => 'return false;', 'id' => 'delete-' . $filename_hash, 'data-delete-file' => $filename, 'data-confirm' => __("Warning! \n" . "You are about to delete a backup, it will be lost forever. \n" . "Are you sure?", 'fw')), esc_html__('Delete', 'fw'));
$this->items[] = array('cb' => fw_html_tag('input', array('type' => 'radio', 'name' => 'archive', 'value' => $filename, 'id' => 'archive-' . $filename_hash)), 'details' => '<div>' . $time . '</div>' . '<div>' . implode(' | ', $details) . '</div>');
}
}
示例5: get_formatted_time
function get_formatted_time($date, $date_format = false, $time_format = false)
{
if (empty($date)) {
return $date;
}
if (!$date_format) {
$date_format = get_option('date_format');
}
if (preg_match('/^\\d{1-2}\\/\\d{1-2}\\/\\d{4}$/', $date)) {
global $frmpro_settings;
$date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
}
$do_time = date('H:i:s', strtotime($date)) == '00:00:00' ? false : true;
$date = get_date_from_gmt($date);
$formatted = date_i18n($date_format, strtotime($date));
if ($do_time) {
if (!$time_format) {
$time_format = get_option('time_format');
}
$trimmed_format = trim($time_format);
if ($time_format and !empty($trimmed_format)) {
$formatted .= ' ' . __('at', 'formidable') . ' ' . date_i18n($time_format, strtotime($date));
}
}
return $formatted;
}
示例6: __invoke
/**
* Reset the post_date field on your posts.
* A sadly necessary step after you change your timezone in WordPress
*
* @synopsis --post_type=<post-type>
*/
public function __invoke($args, $assoc_args)
{
global $wpdb;
$query_args = array('post_type' => $assoc_args['post_type'], 'posts_per_page' => -1, 'post_status' => 'publish');
$query = new WP_Query($query_args);
if (empty($query->posts)) {
WP_CLI::error("No posts found");
}
WP_CLI::line(sprintf("Updating post_date on %d posts.", count($query->posts)));
foreach ($query->posts as $key => $post) {
if (empty($post->post_date_gmt) || "0000-00-00 00:00:00" == $post->post_date_gmt) {
WP_CLI::line(sprintf("Error: Post %d is missing a publish date.", $post->ID));
continue;
}
$original = $post->post_date;
$new = get_date_from_gmt($post->post_date_gmt);
if ($new == $original) {
WP_CLI::line(sprintf("No Change: Post %d has the correct post_date of %s", $post->ID, $original));
continue;
}
$wpdb->update($wpdb->posts, array('post_date' => $new), array('ID' => $post->ID));
clean_post_cache($post->ID);
WP_CLI::line(sprintf("Updated: Post %d changed from %s to %s", $post->ID, $original, $new));
if ($key && $key % 10 == 0) {
sleep(1);
}
}
WP_CLI::success("Posts were updated with the correct post_date.");
}
开发者ID:danielbachhuber,项目名称:wp-cli-reset-post-date-command,代码行数:35,代码来源:wp-cli-reset-post-date-command.php
示例7: test_get_date_from_gmt_during_dst
/**
* Unpatched, this test passes only when Europe/London is observing DST.
*
* @ticket 20328
*/
function test_get_date_from_gmt_during_dst()
{
update_option('timezone_string', 'Europe/London');
$gmt = '2012-06-01 12:34:56';
$local = '2012-06-01 13:34:56';
$this->assertEquals($local, get_date_from_gmt($gmt));
}
示例8: extract_posts
function extract_posts($arg_url)
{
$httpclient = new HTTPClient();
$json_data = $httpclient->send($arg_url, 'get');
if (empty($json_data)) {
$this->message = 'Empty content returned';
return false;
}
// convert json to php array
$array_data = json_decode($json_data, true);
// get data
$facebook_posts = $array_data['data'];
if (count($facebook_posts) > 0) {
foreach ($facebook_posts as $facebook_post) {
$post_content = $facebook_post['message'];
$post_title = $facebook_post['name'];
$post_author = $this->author_id;
$post_status = $this->status_id;
$post_date_gmt = gmdate('Y-m-d H:i:s', strtotime($facebook_post['created_time']));
$post_date = get_date_from_gmt($post_date_gmt);
$facebook_id = $facebook_post['id'];
// build the post array
$this->posts[] = compact('post_content', 'post_title', 'post_author', 'post_status', 'post_date', 'post_date_gmt', 'facebook_id');
}
// end of foreach
}
// end of if
return true;
}
示例9: tc_format_date
function tc_format_date($timestamp, $date_only = false)
{
$format = get_option('date_format');
if (!$date_only) {
$format .= ' - ' . get_option('time_format');
}
$date = get_date_from_gmt(date('Y-m-d H:i:s', $timestamp), $format);
return $date;
}
示例10: test_insert_post_publish_respect_post_date_gmt
/**
* Test that a published post post_date_gmt is not altered
*/
function test_insert_post_publish_respect_post_date_gmt()
{
$post = array('post_author' => self::$admin_user_id, 'post_status' => 'publish', 'post_content' => rand_str(), 'post_title' => rand_str(), 'post_date_gmt' => '2016-04-29 12:00:00');
$id = wp_insert_post($post);
$out = get_post($id);
$this->assertEquals($post['post_content'], $out->post_content);
$this->assertEquals($post['post_title'], $out->post_title);
$this->assertEquals(get_date_from_gmt($post['post_date_gmt']), $out->post_date);
$this->assertEquals($post['post_date_gmt'], $out->post_date_gmt);
}
示例11: is_post_in_sync
/**
* Check if the post is in sync before updating in Apple News.
*
* @access private
* @return boolean
*/
private function is_post_in_sync()
{
$post = get_post($this->id);
if (!$post) {
throw new \Apple_Actions\Action_Exception(__('Could not find post with id ', 'apple-news') . $this->id);
}
$api_time = get_post_meta($this->id, 'apple_news_api_modified_at', true);
$api_time = strtotime(get_date_from_gmt(date('Y-m-d H:i:s', strtotime($api_time))));
$local_time = strtotime($post->post_modified);
$in_sync = $api_time >= $local_time;
return apply_filters('apple_news_is_post_in_sync', $in_sync, $this->id, $api_time, $local_time);
}
示例12: backup
public function backup($backup_array)
{
global $updraftplus, $updraftplus_backup;
$updraft_dir = trailingslashit($updraftplus->backups_dir_location());
$email = $updraftplus->just_one_email(UpdraftPlus_Options::get_updraft_option('updraft_email'), true);
if (!is_array($email)) {
$email = array($email);
}
foreach ($backup_array as $type => $file) {
$descrip_type = preg_match('/^(.*)\\d+$/', $type, $matches) ? $matches[1] : $type;
$fullpath = $updraft_dir . $file;
if (file_exists($fullpath) && filesize($fullpath) > UPDRAFTPLUS_WARN_EMAIL_SIZE) {
$size_in_mb_of_big_file = round(filesize($fullpath) / 1048576, 1);
$toobig_hash = md5($file);
$updraftplus->log($file . ': ' . sprintf(__('This backup archive is %s Mb in size - the attempt to send this via email is likely to fail (few email servers allow attachments of this size). If so, you should switch to using a different remote storage method.', 'updraftplus'), $size_in_mb_of_big_file), 'warning', 'toobigforemail_' . $toobig_hash);
}
$any_attempted = false;
$any_sent = false;
foreach ($email as $ind => $addr) {
if (!apply_filters('updraftplus_email_wholebackup', true, $addr, $ind, $type)) {
continue;
}
foreach (explode(',', $addr) as $sendmail_addr) {
$send_short = strlen($sendmail_addr) > 5 ? substr($sendmail_addr, 0, 5) . '...' : $sendmail_addr;
$updraftplus->log("{$file}: email to: {$send_short}");
$any_attempted = true;
$subject = __("WordPress Backup", 'updraftplus') . ': ' . get_bloginfo('name') . ' (UpdraftPlus ' . $updraftplus->version . ') ' . get_date_from_gmt(gmdate('Y-m-d H:i:s', $updraftplus->backup_time), 'Y-m-d H:i');
$sent = wp_mail(trim($sendmail_addr), $subject, sprintf(__("Backup is of: %s.", 'updraftplus'), site_url() . ' (' . $descrip_type . ')'), null, array($fullpath));
if ($sent) {
$any_sent = true;
}
}
}
if ($any_sent) {
if (isset($toobig_hash)) {
$updraftplus->log_removewarning('toobigforemail_' . $toobig_hash);
// Don't leave it still set for the next archive
unset($toobig_hash);
}
$updraftplus->uploaded_file($file);
} elseif ($any_attempted) {
$updraftplus->log('Mails were not sent successfully');
$updraftplus->log(__('The attempt to send the backup via email failed (probably the backup was too large for this method)', 'updraftplus'), 'error');
} else {
$updraftplus->log('No email addresses were configured to send to');
}
}
return null;
}
示例13: init
public static function init()
{
// SCHEDULER
if (isset($_POST['dh-do-schedule']) && current_user_can('manage_options')) {
wp_clear_scheduled_hook('dh-do-backup');
if ($_POST['dh-do-schedule'] != 'disabled') {
wp_schedule_event(current_time('timestamp', true) + 86400, $_POST['dh-do-schedule'], 'dh-do-backup');
$timestamp = get_date_from_gmt(date('Y-m-d H:i:s', wp_next_scheduled('dh-do-schedule')), get_option('time_format'));
$nextbackup = sprintf(__('Next backup: %s', dreamobjects), $timestamp);
DHDO::logger('Scheduled ' . $_POST['dh-do-schedule'] . ' backup. ' . $nextbackup);
}
}
// RESET
if (current_user_can('manage_options') && isset($_POST['dhdo-reset']) && $_POST['dhdo-reset'] == 'Y') {
delete_option('dh-do-backupsection');
delete_option('dh-do-boto');
delete_option('dh-do-bucket');
delete_option('dh-do-key');
delete_option('dh-do-schedule');
delete_option('dh-do-secretkey');
delete_option('dh-do-section');
delete_option('dh-do-logging');
DHDO::logger('reset');
}
// LOGGER: Wipe logger if blank
if (current_user_can('manage_options') && isset($_POST['dhdo-logchange']) && $_POST['dhdo-logchange'] == 'Y') {
if (!isset($_POST['dh-do-logging'])) {
DHDO::logger('reset');
}
}
// UPDATE OPTIONS
if (isset($_GET['settings-updated']) && isset($_GET['page']) && ($_GET['page'] == 'dreamobjects-menu' || $_GET['page'] == 'dreamobjects-menu-backup')) {
add_action('admin_notices', array('DHDOMESS', 'updateMessage'));
}
// BACKUP ASAP
if (current_user_can('manage_options') && isset($_GET['backup-now']) && $_GET['page'] == 'dreamobjects-menu-backup') {
wp_schedule_single_event(current_time('timestamp', true) + 60, 'dh-do-backupnow');
add_action('admin_notices', array('DHDOMESS', 'backupMessage'));
DHDO::logger('Scheduled ASAP backup in 60 seconds.');
}
// BACKUP
if (wp_next_scheduled('dh-do-backupnow') && ($_GET['page'] == 'dreamobjects-menu' || $_GET['page'] == 'dreamobjects-menu-backup')) {
add_action('admin_notices', array('DHDOMESS', 'backupMessage'));
}
}
示例14: extract_posts_from_data
function extract_posts_from_data($raw)
{
global $wpdb;
$importdata = $raw;
if (null === $importdata) {
$this->finished = true;
return new Keyring_Error('keyring-instapaper-importer-failed-download', __('Failed to download or parse your links from Instapaper. Please wait a few minutes and try again.'));
}
// Make sure we have some bookmarks to parse
if (!is_array($importdata) || count($importdata) < 2) {
$this->finished = true;
return;
}
usort($importdata, array($this, 'sort_by_time'));
// Parse/convert everything to WP post structs
foreach ($importdata as $post) {
if ('bookmark' != $post->type) {
continue;
}
$post_title = $post->title;
// Parse/adjust dates
$post_date_gmt = gmdate('Y-m-d H:i:s', $post->progress_timestamp);
// last seen "progress"
$post_date = get_date_from_gmt($post_date_gmt);
// Apply selected category
$post_category = array($this->get_option('category'));
// Just default tags here
$tags = $this->get_option('tags');
// Construct a post body
$href = $post->url;
$post_content = '<a href="' . $href . '" class="instapaper-title">' . $post_title . '</a>';
if (!empty($post->description)) {
$post_content .= "\n\n<blockquote class='instapaper-note'>" . $post->description . '</blockquote>';
}
// Other bits
$post_author = $this->get_option('author');
$post_status = 'publish';
$instapaper_id = $post->bookmark_id;
$instapaper_raw = $post;
// Build the post array, and hang onto it along with the others
$this->posts[] = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_status', 'post_category', 'tags', 'href', 'instapaper_id', 'instapaper_raw');
}
}
示例15: yith_vendors_update_db_1_0_1
function yith_vendors_update_db_1_0_1()
{
$vendors_db_option = get_option('yith_product_vendors_db_version', '1.0.0');
if ($vendors_db_option && version_compare($vendors_db_option, '1.0.1', '<')) {
global $wpdb;
$sql = "SELECT woocommerce_term_id as vendor_id, meta_value as user_id\r\n FROM {$wpdb->woocommerce_termmeta} as wtm\r\n WHERE wtm.meta_key = %s\r\n AND woocommerce_term_id IN (\r\n SELECT DISTINCT term_id as vendor_id\r\n FROM {$wpdb->term_taxonomy} as tt\r\n WHERE tt.taxonomy = %s\r\n )";
$results = $wpdb->get_results($wpdb->prepare($sql, 'owner', YITH_Vendors()->get_taxonomy_name()));
foreach ($results as $result) {
$user = get_user_by('id', $result->user_id);
if ($user) {
update_woocommerce_term_meta($result->vendor_id, 'registration_date', get_date_from_gmt($user->user_registered));
update_woocommerce_term_meta($result->vendor_id, 'registration_date_gmt', $user->user_registered);
if (defined('YITH_WPV_PREMIUM')) {
$user->add_cap('view_woocommerce_reports');
}
}
}
update_option('yith_product_vendors_db_version', '1.0.1');
}
}