• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP timezone_offset_get函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: __construct

 public function __construct()
 {
     global $wpdb;
     if (get_option('timezone_string')) {
         $this->tz_offset = timezone_offset_get(timezone_open(get_option('timezone_string')), new DateTime());
     } else {
         if (get_option('gmt_offset')) {
             $this->tz_offset = get_option('gmt_offset') * 60 * 60;
         }
     }
     $this->db = $wpdb;
     $this->tb_prefix = $wpdb->prefix;
     $this->agent = $this->get_UserAgent();
     $this->historical = array();
     // Load the options from the database
     $this->options = get_option('wp_statistics');
     // Set the default co-efficient.
     $this->coefficient = $this->get_option('coefficient', 1);
     // Double check the co-efficient setting to make sure it's not been set to 0.
     if ($this->coefficient <= 0) {
         $this->coefficient = 1;
     }
     // This is a bit of a hack, we strip off the "includes/classes" at the end of the current class file's path.
     $this->plugin_dir = substr(dirname(__FILE__), 0, -17);
     $this->plugin_url = substr(plugin_dir_url(__FILE__), 0, -17);
     $this->get_IP();
     if ($this->get_option('hash_ips') == true) {
         $this->ip_hash = '#hash#' . sha1($this->ip + $_SERVER['HTTP_USER_AGENT']);
     }
 }
开发者ID:bqevin,项目名称:wp-shopeasy,代码行数:30,代码来源:statistics.class.php


示例2: getSchedule

 /**
  * Get weekly shedule for a particular day
  *
  * @param $timestamp
  * @return array
  */
 function getSchedule($timestamp)
 {
     if (!$this->magister->personData) {
         return 403;
     }
     $tz = timezone_open('Europe/Amsterdam');
     $tz_offset = timezone_offset_get($tz, new \DateTime('@' . $timestamp, timezone_open('UTC')));
     $timestamp += $tz_offset + 4;
     $weekstart = $this->getFirstDayOfWeek(date('Y', $timestamp), date('W', $timestamp));
     $weekend = strtotime('this Friday', $weekstart);
     $data = $this->magister->personRequest('afspraken?status=1&tot=' . date('Y-m-d', $weekend) . '&van=' . date('Y-m-d', $weekstart))->Items;
     $result = array('week_timestamp' => $weekstart, 'days' => array());
     $curday = $weekstart;
     while ($curday <= $weekend) {
         $result['days'][(int) date('w', $curday)] = array('day_title' => $this->dutchDayName($curday), 'day_ofweek' => (int) date('w', $curday), 'items' => array());
         $curday += 86400;
     }
     foreach ($data as $item) {
         $start = strtotime($item->Start) + $tz_offset;
         $curwd = date('w', $start);
         if ($item->DuurtHeleDag) {
             $result['days'][(int) $curwd]['items'][] = array('title' => $item->Omschrijving, 'subtitle' => $item->Lokatie, 'start' => $start, 'start_str' => 'DAG');
         } else {
             $result['days'][(int) $curwd]['items'][] = array('title' => $item->LesuurVan . '. ' . $item->Vakken[0]->Naam, 'subtitle' => 'Lokaal ' . $item->Lokalen[0]->Naam, 'start' => $start, 'start_str' => date('H:i', $start + $tz_offset));
         }
     }
     foreach ($result['days'] as $index => $day) {
         if (empty($day['items'])) {
             unset($result['days'][$index]);
         }
     }
     return $result;
 }
开发者ID:wvanbreukelen,项目名称:api.lesrooster.io,代码行数:39,代码来源:Handler.php


示例3: testUsingYiiTimeZoneSwitcherWithPhpTimeFunction

 public function testUsingYiiTimeZoneSwitcherWithPhpTimeFunction()
 {
     $oldTimeZone = Yii::app()->getTimeZone();
     $dateTimeUtc = new DateTime();
     $timeStamp = time();
     //always UTC regardless of server timezone or any timezone setting.
     Yii::app()->setTimeZone('UTC');
     $dateStamp = date("Y-m-d G:i", $timeStamp);
     Yii::app()->setTimeZone('America/Chicago');
     $dateStamp2 = date("Y-m-d G:i", $timeStamp);
     Yii::app()->setTimeZone('America/New_York');
     $timeZoneObject = new DateTimeZone('America/New_York');
     $offset = $timeZoneObject->getOffset(new DateTime());
     $this->assertTrue($offset == -18000 || $offset == -14400);
     $newYorkTimeZone = new DateTimeZone(date_default_timezone_get());
     $offset1 = $newYorkTimeZone->getOffset($dateTimeUtc);
     $offset2 = timezone_offset_get($newYorkTimeZone, $dateTimeUtc);
     $this->assertEquals($offset, $offset1);
     $this->assertEquals($offset, $offset2);
     if ($offset == -18000) {
         $offsetHours = 6;
     } else {
         $offsetHours = 5;
     }
     $dateStamp3 = date("Y-m-d G:i", $timeStamp);
     $this->assertEquals(strtotime($dateStamp), strtotime($dateStamp2) + 3600 * $offsetHours);
     // + 5 from GMT or +6 depending on DST
     $this->assertEquals(strtotime($dateStamp3), strtotime($dateStamp2) + 3600 * 1);
     // + 1 from NY
     //Use retrieved offset based on timezone.
     Yii::app()->setTimeZone($oldTimeZone);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:32,代码来源:TimeZoneTest.php


示例4: __construct

 /**
  * Constructor.  Pass in the global configuration object
  *
  * @param type $conf
  */
 function __construct($conf)
 {
     $this->load = new Loader();
     if (empty($conf)) {
         return;
     }
     $timezone = ini_get('date.timezone');
     if (!$timezone) {
         $system_timezone = exec('date +%Z');
         date_default_timezone_set($system_timezone);
         $timezone = date_default_timezone_get();
     }
     $this->timezone_offset = timezone_offset_get(new DateTimeZone($timezone), new DateTime());
     $this->conf = $conf;
     $this->data_model = new AnemometerModel($conf);
     if (array_key_exists('time_columns', $this->conf)) {
         $this->time_columns = $this->conf['time_columns'];
     } else {
         $this->time_columns = array();
     }
     $datasource = get_var('datasource');
     if (isset($datasource)) {
         $this->data_model->set_data_source($datasource);
         $this->data_model->connect_to_datasource();
     }
     $this->init_report();
     session_start();
 }
开发者ID:asura0129,项目名称:Anemometer,代码行数:33,代码来源:Anemometer.php


示例5: getOffset

 private function getOffset($tz)
 {
     if ($tz == '') {
         return 0;
     }
     # Heure GMT
     return timezone_offset_get(new \DateTimeZone($tz), new \DateTime());
 }
开发者ID:AxelANGENAULT,项目名称:CoreBundle,代码行数:8,代码来源:AriiDate.php


示例6: format_date

function format_date($format, $timestamp = null)
{
    global $timezone;
    if ($timestamp == null) {
        $timestamp = time();
    }
    $timestamp = $timestamp + timezone_offset_get(new DateTimeZone($timezone), new DateTime());
    return date($format, $timestamp);
}
开发者ID:arpitchakraborty,项目名称:checklist-082,代码行数:9,代码来源:index.php


示例7: testOutreachPunchcardInsight

 public function testOutreachPunchcardInsight()
 {
     $cfg = Config::getInstance();
     $install_timezone = new DateTimeZone($cfg->getValue('timezone'));
     $owner_timezone = new DateTimeZone($test_timezone = 'America/Los_Angeles');
     // Get data ready that insight requires
     $posts = self::getTestPostObjects();
     $post_pub_date = new DateTime($posts[0]->pub_date);
     $now = new DateTime();
     $offset = timezone_offset_get($owner_timezone, $now) - timezone_offset_get($install_timezone, $now);
     $post_dotw = date('N', date('U', strtotime($posts[0]->pub_date)) + timezone_offset_get($owner_timezone, $now));
     $post_hotd = date('G', date('U', strtotime($posts[0]->pub_date)) + timezone_offset_get($owner_timezone, $now));
     $builders = array();
     $builders[] = FixtureBuilder::build('users', array('user_id' => '7654321', 'user_name' => 'twitteruser', 'full_name' => 'Twitter User', 'avatar' => 'avatar.jpg', 'follower_count' => 36000, 'is_protected' => 0, 'network' => 'twitter', 'description' => 'A test Twitter User'));
     $instance_id = 10;
     $builders[] = FixtureBuilder::build('owners', array('id' => 1, 'full_name' => 'ThinkUp J. User', 'email' => '[email protected]', 'is_activated' => 1, 'email_notification_frequency' => 'never', 'is_admin' => 0, 'timezone' => $test_timezone));
     $builders[] = FixtureBuilder::build('owner_instances', array('owner_id' => '1', 'instance_id' => $instance_id));
     $install_offset = $install_timezone->getOffset(new DateTime());
     $date_r = date("Y-m-d", strtotime('-1 day') - $install_offset);
     // Response between 1pm and 2pm install time
     $time = gmdate('Y-m-d H:i:s', strtotime('yesterday 13:11:09'));
     $builders[] = FixtureBuilder::build('posts', array('id' => 136, 'post_id' => 136, 'author_user_id' => 7654321, 'author_username' => 'twitteruser', 'author_fullname' => 'Twitter User', 'author_avatar' => 'avatar.jpg', 'network' => 'twitter', 'post_text' => 'This is a reply.', 'source' => 'web', 'pub_date' => $time, 'in_reply_to_post_id' => 133, 'reply_count_cache' => 0, 'is_protected' => 0));
     // Response between 1pm and 2pm install time
     $time = gmdate('Y-m-d H:i:s', strtotime('yesterday 13:01:13'));
     $builders[] = FixtureBuilder::build('posts', array('id' => 137, 'post_id' => 137, 'author_user_id' => 7654321, 'author_username' => 'twitteruser', 'author_fullname' => 'Twitter User', 'author_avatar' => 'avatar.jpg', 'network' => 'twitter', 'post_text' => 'This is a reply.', 'source' => 'web', 'pub_date' => $time, 'in_reply_to_post_id' => 133, 'reply_count_cache' => 0, 'is_protected' => 0));
     // Response between 1pm and 2pm install time
     $time = gmdate('Y-m-d H:i:s', strtotime('yesterday 13:13:56'));
     $builders[] = FixtureBuilder::build('posts', array('id' => 138, 'post_id' => 138, 'author_user_id' => 7654321, 'author_username' => 'twitteruser', 'author_fullname' => 'Twitter User', 'author_avatar' => 'avatar.jpg', 'network' => 'twitter', 'post_text' => 'This is a reply.', 'source' => 'web', 'pub_date' => $time, 'in_reply_to_post_id' => 135, 'reply_count_cache' => 0, 'is_protected' => 0));
     // Response between 11am and 12pm install time
     $time = gmdate('Y-m-d H:i:s', strtotime('yesterday 11:07:42'));
     $builders[] = FixtureBuilder::build('posts', array('id' => 139, 'post_id' => 139, 'author_user_id' => 7654321, 'author_username' => 'twitteruser', 'author_fullname' => 'Twitter User', 'author_avatar' => 'avatar.jpg', 'network' => 'twitter', 'source' => 'web', 'post_text' => 'RT @testeriffic: New Year\'s Eve! Feeling very gay today, but not very homosexual.', 'pub_date' => $time, 'in_retweet_of_post_id' => 134, 'reply_count_cache' => 0, 'is_protected' => 0));
     $time1str_low = date('ga', date('U', strtotime($date_r . ' 13:00:00')) + $offset);
     $time1str_high = date('ga', date('U', strtotime($date_r . ' 14:00:00')) + $offset);
     $time1str = $time1str_low . " and " . $time1str_high;
     $time2str_low = date('ga', date('U', strtotime($date_r . ' 11:00:00')) + $offset);
     $time2str_high = date('ga', date('U', strtotime($date_r . ' 12:00:00')) + $offset);
     $time2str = $time2str_low . " and " . $time2str_high;
     $instance = new Instance();
     $instance->id = $instance_id;
     $instance->network_username = 'testeriffic';
     $instance->network = 'twitter';
     $insight_plugin = new OutreachPunchcardInsight();
     $insight_plugin->generateInsight($instance, $posts, 3);
     // Assert that insight got inserted with correct punchcard information
     $insight_dao = new InsightMySQLDAO();
     $today = date('Y-m-d');
     $result = $insight_dao->getInsight('outreach_punchcard', 10, $today);
     $punchcard = unserialize($result->related_data);
     $this->debug(Utils::varDumpToString($result));
     $this->assertNotNull($result);
     $this->assertIsA($result, "Insight");
     $this->assertEqual($punchcard['posts'][$post_dotw][$post_hotd], 3);
     $this->assertPattern('/\\@testeriffic\'s tweets from last week got/', $result->text);
     $this->assertPattern('/<strong>3 responses<\\/strong> between <strong>' . $time1str . '<\\/strong>/', $result->text);
     $this->assertPattern('/as compared to <strong>1 response<\\/strong>/', $result->text);
     $this->assertPattern('/<strong>1 response<\\/strong> between <strong>' . $time2str . '<\\/strong>/', $result->text);
 }
开发者ID:dgw,项目名称:ThinkUp,代码行数:57,代码来源:TestOfOutreachPunchcardInsight.php


示例8: getOffset

 private function getOffset($tz)
 {
     if ($tz == '') {
         // ATTENTION !!!!!!!!!!!!!!!!!!!!!!!!!!!
         $tz = 'GMT';
     }
     if ($tz == 'GMT') {
         $offset = 0;
     } else {
         $offset = timezone_offset_get(new \DateTimeZone($tz), new \DateTime());
     }
     return $offset;
 }
开发者ID:AriiPortal,项目名称:Arii,代码行数:13,代码来源:AriiDate.php


示例9: timezone_offset

 /**
  * Utility method that returns time string offset by timezone
  * @since  1.0.0
  * @param  string $tzstring Time string
  * @return string           Offset time string
  */
 public function timezone_offset($tzstring)
 {
     if (!empty($tzstring) && is_string($tzstring)) {
         if ('UTC' === substr($tzstring, 0, 3)) {
             $tzstring = str_replace(array(':15', ':30', ':45'), array('.25', '.5', '.75'), $tzstring);
             return intval(floatval(substr($tzstring, 3)) * HOUR_IN_SECONDS);
         }
         $date_time_zone_selected = new DateTimeZone($tzstring);
         $tz_offset = timezone_offset_get($date_time_zone_selected, date_create());
         return $tz_offset;
     }
     return 0;
 }
开发者ID:kps3,项目名称:wordpress-base,代码行数:19,代码来源:CMB2_Utils.php


示例10: zoneInfo

	/**
	 * Return a set of timezone information relevant to this joyful stuff :D
	 */
	public static function zoneInfo() {
		$zones = array();
		$now = date_create();
		foreach( timezone_identifiers_list() as $tz ) {
			$zone = timezone_open( $tz );

			$name = timezone_name_get( $zone );
			$location = timezone_location_get( $zone );
			$offset = timezone_offset_get( $zone, $now ) / 60; // convert seconds to minutes

			$zones[] = array('name' => $name, 'offset' => $offset, 'location' => $location);
		}
		return $zones;
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:17,代码来源:TimeZonePicker.hooks.php


示例11: timezone_offset

 /**
  * Utility method that returns time string offset by timezone
  * @since  1.0.0
  * @param  string $tzstring Time string
  * @return string           Offset time string
  */
 public function timezone_offset($tzstring)
 {
     $tz_offset = 0;
     if (!empty($tzstring) && is_string($tzstring)) {
         if ('UTC' === substr($tzstring, 0, 3)) {
             $tzstring = str_replace(array(':15', ':30', ':45'), array('.25', '.5', '.75'), $tzstring);
             return intval(floatval(substr($tzstring, 3)) * HOUR_IN_SECONDS);
         }
         try {
             $date_time_zone_selected = new DateTimeZone($tzstring);
             $tz_offset = timezone_offset_get($date_time_zone_selected, date_create());
         } catch (Exception $e) {
             $this->log_if_debug(__METHOD__, __LINE__, $e->getMessage());
         }
     }
     return $tz_offset;
 }
开发者ID:markbiek,项目名称:Silencio,代码行数:23,代码来源:CMB2_Utils.php


示例12: init

 public function init()
 {
     parent::init();
     $session = Yii::app()->session;
     $timezone = $session->get("timezone");
     if (is_null($timezone)) {
         $timezone = date_default_timezone_get();
     }
     if (!$this->isValidTimeZone($timezone)) {
         $timezone = date_default_timezone_get();
     }
     $this->timezone = $timezone;
     $this->phpTimezone = date_default_timezone_get();
     $this->timezoneOffset = timezone_offset_get(new DateTimeZone($this->timezone), new DateTime());
     $this->phpTimezoneOffset = timezone_offset_get(new DateTimeZone($this->phpTimezone), new DateTime());
     //Yii::log("TimeZoneFix::init timezone=[{$this->timezone}],phpTimezone=[{$this->phpTimezone}],timezoneOffset=[{$this->timezoneOffset}],phpTimezoneOffset=[{$this->phpTimezoneOffset},lan=[".Yii::app()->language."]","info");
 }
开发者ID:alexanderkuz,项目名称:test-yii2,代码行数:17,代码来源:TimeZoneFix.php


示例13: exportDataSeriesOptions

 protected function exportDataSeriesOptions(Flot\DataSeries $dataSeries)
 {
     $options = $dataSeries->getOptions();
     $data = iterator_to_array($dataSeries->getData());
     $options['data'] = array_map(function (Flot\DataValue $value) {
         if ($value->key instanceof \DateTime) {
             $timestamp = (int) $value->key->format('U') + timezone_offset_get($value->key->getTimezone(), $value->key);
             return [$timestamp * 1000, (double) $value->value];
         } else {
             return [(int) $value->key, (double) $value->value];
         }
     }, array_values($data));
     foreach ($dataSeries->getTypes() as $type) {
         $options[$type->getIdentifier()] = $this->exportTypeOptions($type);
     }
     return $options;
 }
开发者ID:librette,项目名称:flot,代码行数:17,代码来源:FlotRenderer.php


示例14: filter

 /**
  * Filter the supplied input string to an ISO date.
  *
  * @param string $value
  * @return null|string
  */
 public function filter($value)
 {
     if (null === $value || '' === $value) {
         $out = null;
     } else {
         $gmtOffset = 0;
         // Reverse WordPress GMT offset when filtering date input
         if (function_exists('get_option')) {
             $timezoneString = get_option('timezone_string');
             $isoValue = date('Y-m-d H:i:s', strtotime($value));
             if ($timezoneString) {
                 $gmtOffset = timezone_offset_get(new DateTimeZone($timezoneString), date_create($isoValue));
             }
         }
         $out = date('Y-m-d H:i:s', strtotime($value) + $gmtOffset * -1);
     }
     return $out;
 }
开发者ID:deltasystems,项目名称:dewdrop,代码行数:24,代码来源:IsoTimestamp.php


示例15: timezone_offset

 /**
  * Utility method that returns time string offset by timezone
  * @since  1.0.0
  * @param  string $tzstring Time string
  * @return string           Offset time string
  */
 public function timezone_offset($tzstring)
 {
     $tz_offset = 0;
     if (!empty($tzstring) && is_string($tzstring)) {
         if ('UTC' === substr($tzstring, 0, 3)) {
             $tzstring = str_replace(array(':15', ':30', ':45'), array('.25', '.5', '.75'), $tzstring);
             return intval(floatval(substr($tzstring, 3)) * HOUR_IN_SECONDS);
         }
         try {
             $date_time_zone_selected = new DateTimeZone($tzstring);
             $tz_offset = timezone_offset_get($date_time_zone_selected, date_create());
         } catch (Exception $e) {
             if (defined('WP_DEBUG') && WP_DEBUG) {
                 error_log('CMB2_Sanitize:::text_datetime_timestamp_timezone, ' . __LINE__ . ': ' . print_r($e->getMessage(), true));
             }
         }
     }
     return $tz_offset;
 }
开发者ID:jrajalu,项目名称:myxon,代码行数:25,代码来源:CMB2_Utils.php


示例16: __construct

 function __construct($connect_data)
 {
     $this->tz_offset = timezone_offset_get(timezone_open(date_default_timezone_get()), new DateTime());
     $this->FTP_STATE_NAME = array(0 => 'DISCONNECTED', 1 => 'CONNECTED', 2 => 'LOGGED IN', 3 => 'TARGETED');
     $this->FTP_STATUS_NAME = array(-1 => 'ERROR', 0 => 'READY', 1 => 'READING', 2 => 'NOT READ');
     $this->months = array("Jan" => 1, "Feb" => 2, "Mar" => 3, "Apr" => 4, "May" => 5, "Jun" => 6, "Jul" => 7, "Aug" => 8, "Sep" => 9, "Oct" => 10, "Nov" => 11, "Dec" => 12);
     $this->user = $connect_data['username'];
     $this->pass = $connect_data['password'];
     $this->listing_cache = array();
     if (isset($connect_data['port'])) {
         $this->port = $connect_data['port'];
     } else {
         $this->port = 21;
     }
     $this->host = $connect_data['host'];
     if (isset($connect_data['path'])) {
         $this->cur_path = $connect_data['path'];
     } else {
         $this->cur_path = '';
     }
 }
开发者ID:revsm,项目名称:procureor,代码行数:21,代码来源:ftpclient.php


示例17: cmsms

/**
 * A method to re-initialize connections to the CMSMS configured database.
 * This method should be used by any UDT's or other plugins that use any other method
 * than the standard CMSMS supplied database object to connect to a database.
 *
 */
function &adodb_connect()
{
    $gCms = cmsms();
    $config = $gCms->GetConfig();
    $str = 'pear:date:extend';
    $dbinstance = ADONewConnection($config['dbms'], $str);
    $dbinstance->raiseErrorFn = "adodb_error";
    $conn_func = isset($config['persistent_db_conn']) && $config['persistent_db_conn'] == true ? 'PConnect' : 'Connect';
    if (!empty($config['db_port'])) {
        $dbinstance->port = $config['db_port'];
    }
    $connect_result = $dbinstance->{$conn_func}($config['db_hostname'], $config['db_username'], $config['db_password'], $config['db_name']);
    if (FALSE == $connect_result) {
        $str = "Attempt to connect to database {$config['db_name']} on {$config['db_username']}@{$config['db_hostname']} failed";
        trigger_error($str, E_USER_ERROR);
        die($str);
    }
    $dbinstance->raiseErrorFn = null;
    $dbinstance->SetFetchMode(ADODB_FETCH_ASSOC);
    if ($config['debug'] == true) {
        $dbinstance->debug = true;
    }
    $p1 = array();
    if ($config['set_names'] == true) {
        $p1[] = "NAMES 'utf8'";
    }
    if ($config['set_db_timezone'] == true) {
        $dt = new DateTime();
        $dtz = new DateTimeZone($config['timezone']);
        $offset = timezone_offset_get($dtz, $dt);
        $symbol = $offset < 0 ? '-' : '+';
        $hrs = abs((int) ($offset / 3600));
        $mins = abs((int) ($offset % 3600));
        $p1[] = sprintf("time_zone = '%s%d:%02d'", $symbol, $hrs, $mins);
    }
    $dbinstance->Execute('SET ' . implode(',', $p1));
    return $dbinstance;
}
开发者ID:Alexkuva,项目名称:Beaupotager,代码行数:44,代码来源:adodb.functions.php


示例18: transformAppointmentsToHtml

/**
 * Diese Funktion transformiert die Daten, die von der Funktion getAppointmentByResource erstellt wurden,
 * in eine Datenstruktur, die auf der Oberfläche geparsed und angezeigt werden kann.
 */
function transformAppointmentsToHtml($result, $exclude_id, $class, $tag_ende, $tag_offset)
{
    $data = "";
    foreach ($result as $values) {
        $appointment_id = $values["ID"];
        $output = getEventOfAppointment($appointment_id);
        $output .= getRessourcesOfAppointment($appointment_id, $exclude_id);
        $duration = ($values["end_ts"] - $values["begin_ts"]) / 3600;
        //Achtung: begin_ts ist der timestamp des ersten TERMINS! Wir erhalten also in der Differenz mit dem Anfragedatum mehrere Tage Unterschied
        //AUSSERDEM: Zeitzonen-Problem!!!!
        //Erster Schritt: Berechne die Anzahl der Tage die zwischen dem ersten Serientermin und heute liegt:
        $anzahlTage = floor(($tag_ende - $values["begin_ts"]) / SECS_PER_DAY);
        //Zweiter Schritt: Prüfe die Gleichheit der Zeitzonen!
        $objDateTimeZone = timezone_open(date_default_timezone_get());
        $date = date("Y-m-d h:i:s", $values["begin_ts"]);
        $timezoneDiffOriginal = $strZeitzoneUnterschiedZuGMT = timezone_offset_get($objDateTimeZone, date_create($date, $objDateTimeZone));
        $timezoneDiffCurrent = $strZeitzoneUnterschiedZuGMT = timezone_offset_get($objDateTimeZone, date_create("now", $objDateTimeZone));
        //echo "begin_ts:".$values["begin_ts"]."anzahlTage:".$anzahlTage."tag_offset:".$tag_offset."tag_ende:".$tag_ende;
        $start = ($values["begin_ts"] + $anzahlTage * SECS_PER_DAY - $tag_offset) / 3600 + ($timezoneDiffOriginal - $timezoneDiffCurrent) / 3600;
        $data .= "<li class='" . $class . "' data-start='" . $start . "' data-duration='" . $duration . "'><ul class='ttEventDetails'>" . $output . "</ul></li>";
    }
    return $data;
}
开发者ID:rapla,项目名称:rapla.freiraum-p,代码行数:27,代码来源:functions.php


示例19: formatTimeAgo

 /**
  * returns a string from array returned by Date::timeAgo()
  * @param $time unix epoch
  * @param $from from unix epoch
  * @param $format array of periods to show
  */
 public static function formatTimeAgo($from, $to, $format = array('year', 'month', 'day', 'hour', 'minute', 'second'))
 {
     // have to calculate the offset
     $default_timezone = timezone_open(date_default_timezone_get());
     $from_datetime = new DateTime(date('Y-m-d H:i:s', $from));
     // add the offset
     $from += timezone_offset_get($default_timezone, $from_datetime);
     $timeago = Date::timeAgo($from, $to);
     $t = array();
     foreach ($format as $period) {
         if (isset($timeago[$period])) {
             $time = $timeago[$period];
             if ($time != 1) {
                 $period .= 's';
             }
             $t[] = "{$time} [{$period}]";
         }
     }
     $t = implode(" ", $t);
     if (!trim($t)) {
         return (string) '0';
     }
     return $t;
 }
开发者ID:ThibautLeger,项目名称:123-mini,代码行数:30,代码来源:Date.php


示例20: getTimezoneOptions

	/**
	 * @param $context IContextSource
	 * @return array
	 */
	static function getTimezoneOptions( IContextSource $context ) {
		$opt = array();

		global $wgLocalTZoffset;
		$timestamp = MWTimestamp::getLocalInstance();
		// Check that $wgLocalTZoffset is the same as the local time zone offset
		if ( $wgLocalTZoffset == $timestamp->format( 'Z' ) / 60 ) {
			$server_tz_msg = $context->msg( 'timezoneuseserverdefault', $timestamp->getTimezone()->getName() )->text();
		} else {
			$tzstring = sprintf( '%+03d:%02d', floor( $wgLocalTZoffset / 60 ), abs( $wgLocalTZoffset ) % 60 );
			$server_tz_msg = $context->msg( 'timezoneuseserverdefault', $tzstring )->text();
		}
		$opt[$server_tz_msg] = "System|$wgLocalTZoffset";
		$opt[$context->msg( 'timezoneuseoffset' )->text()] = 'other';
		$opt[$context->msg( 'guesstimezone' )->text()] = 'guess';

		if ( function_exists( 'timezone_identifiers_list' ) ) {
			# Read timezone list
			$tzs = timezone_identifiers_list();
			sort( $tzs );

			$tzRegions = array();
			$tzRegions['Africa'] = $context->msg( 'timezoneregion-africa' )->text();
			$tzRegions['America'] = $context->msg( 'timezoneregion-america' )->text();
			$tzRegions['Antarctica'] = $context->msg( 'timezoneregion-antarctica' )->text();
			$tzRegions['Arctic'] = $context->msg( 'timezoneregion-arctic' )->text();
			$tzRegions['Asia'] = $context->msg( 'timezoneregion-asia' )->text();
			$tzRegions['Atlantic'] = $context->msg( 'timezoneregion-atlantic' )->text();
			$tzRegions['Australia'] = $context->msg( 'timezoneregion-australia' )->text();
			$tzRegions['Europe'] = $context->msg( 'timezoneregion-europe' )->text();
			$tzRegions['Indian'] = $context->msg( 'timezoneregion-indian' )->text();
			$tzRegions['Pacific'] = $context->msg( 'timezoneregion-pacific' )->text();
			asort( $tzRegions );

			$prefill = array_fill_keys( array_values( $tzRegions ), array() );
			$opt = array_merge( $opt, $prefill );

			$now = date_create( 'now' );

			foreach ( $tzs as $tz ) {
				$z = explode( '/', $tz, 2 );

				# timezone_identifiers_list() returns a number of
				# backwards-compatibility entries. This filters them out of the
				# list presented to the user.
				if ( count( $z ) != 2 || !array_key_exists( $z[0], $tzRegions ) ) {
					continue;
				}

				# Localize region
				$z[0] = $tzRegions[$z[0]];

				$minDiff = floor( timezone_offset_get( timezone_open( $tz ), $now ) / 60 );

				$display = str_replace( '_', ' ', $z[0] . '/' . $z[1] );
				$value = "ZoneInfo|$minDiff|$tz";

				$opt[$z[0]][$display] = $value;
			}
		}
		return $opt;
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:66,代码来源:Preferences.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP timezone_open函数代码示例发布时间:2022-05-23
下一篇:
PHP timezone_name_from_abbr函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap