本文整理汇总了PHP中timezone_open函数的典型用法代码示例。如果您正苦于以下问题:PHP timezone_open函数的具体用法?PHP timezone_open怎么用?PHP timezone_open使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了timezone_open函数的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: toApiArray
/**
* @return array order data in API form
* @throws PilipayError
*/
public function toApiArray()
{
// check goods list
if (empty($this->_goodsList)) {
throw new PilipayError(PilipayError::REQUIRED_ARGUMENT_NO_EXIST, array('name' => 'goodsList', 'value' => Tools::jsonEncode($this->_goodsList)));
}
// if the orderTime is omitted, use current time
if (empty($this->orderTime)) {
$now = date_create('now', timezone_open('Asia/Shanghai'))->format('Y-m-d H:i:s');
$this->orderTime = $this->orderTime ? $this->orderTime : $now;
}
// verify
parent::verifyFields();
$apiArray = array_map('strval', array('version' => $this->version, 'merchantNo' => $this->merchantNo, 'currencyType' => $this->currencyType, 'orderNo' => $this->orderNo, 'orderAmount' => (int) round($this->orderAmount * 100), 'orderTime' => $this->orderTime, 'pageUrl' => $this->pageUrl, 'serverUrl' => $this->serverUrl, 'redirectUrl' => $this->redirectUrl, 'notifyType' => $this->notifyType, 'shipper' => (int) round($this->shipper * 100), 'tax' => (int) round($this->tax * 100), 'signType' => $this->signType));
// sign
if ($this->signType == 'MD5') {
// sign using MD5
$this->signMsg = md5(implode('', $apiArray) . $this->appSecret);
$apiArray['signMsg'] = $this->signMsg;
} else {
throw new PilipayError(PilipayError::INVALID_ARGUMENT, array('name' => 'signType', 'value' => $this->signType));
}
$apiArray['goodsList'] = urlencode(Tools::jsonEncode($this->_goodsList));
return $apiArray;
}
开发者ID:pilibaba,项目名称:pilipay-for-prestashop,代码行数:29,代码来源:PilipayOrder.php
示例3: print_comment_item
function print_comment_item($tag, $id, $author, $date, $comment)
{
global $domain;
$output = "";
$output .= " <item>\n";
$output .= " <title>#";
$output .= $id;
$output .= " on tag ";
$output .= $tag;
$output .= " by ";
$output .= htmlentities($author);
$output .= "</title>\n";
$output .= " <link>";
$output .= $domain . href('tag/' . $tag . '#comment-' . $id);
$output .= "</link>\n";
$output .= " <description>A new comment by ";
$output .= $author;
$output .= " on tag ";
$output .= $tag;
$output .= ".";
$output .= "</description>\n";
$output .= " <content:encoded><![CDATA[";
$output .= Markdown(htmlspecialchars($comment));
$output .= "]]></content:encoded>\n";
$output .= " <dc:creator>";
$output .= $author;
$output .= "</dc:creator>\n";
$output .= " <pubDate>";
$output .= date_format(date_create($date, timezone_open('GMT')), DATE_RFC2822);
$output .= "</pubDate>\n";
$output .= " </item>\n";
return $output;
}
开发者ID:robertcardona,项目名称:stacks-website,代码行数:33,代码来源:commentsfeed.php
示例4: 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
示例5: sendDataToAPI
function sendDataToAPI($data)
{
//get JSON from Source and parse it
$arr = json_decode($data, true);
$date = DateTime::createFromFormat("U", $arr["timestamp"], timezone_open("Europe/Berlin"));
$date = date_format($date, 'Y-m-d');
//Make a new JSON in the format described on page X of the API Documentation
$json = '{
"originalId":"11111",
"attributes":{
},
"externalSourceId":36,
"geoBlobDates":[
{
"valid":{
"since":"' . $date . '",
"until":"3000-01-01"
}
},
{
"valid":{
"since":"' . $date . '",
"until":"3000-01-01"
}
}
],
"tagDates":[
{
"tags":{
"data":"true",
"substance":"' . $arr["substance"] . '",
"value":"' . $arr["value"] . '",
"unit":"' . $arr["unit"] . '",
"timestamp":' . $arr["timestamp"] . '
},
"valid":{
"since":"' . $date . '",
"until":"3000-01-01"
}
}
],
"geometricObjects":[
{
"valid":{
"since":"' . $date . '",
"until":"' . $date . '"
},
"multipoint":"MULTIPOINT(' . $arr["lon"] . ' ' . $arr["lat"] . ' 0)"
}
]
}';
//send this
$url = "http://ohsm.f4.htw-berlin.de:8080/OhdmApi/geographicObject/";
$connection_options = $this->buildConnection("PUT", $json);
$arr["response"] = file_get_contents($url, false, $connection_options);
$arr["status"] = substr($http_response_header[0], 9, 3);
//return the answer
return $arr;
}
开发者ID:OHDMax,项目名称:OHDM-SDC,代码行数:59,代码来源:SDC_model.php
示例6: sortPublishDateDesc
function sortPublishDateDesc($fb, $sb)
{
if (date_create_from_format("Y-m-d", $fb[4], timezone_open("Europe/Sofia")) > date_create_from_format("Y-m-d", $sb[4], timezone_open("Europe/Sofia"))) {
return -1;
} else {
return 1;
}
}
开发者ID:KonstantinKirchev,项目名称:PHP,代码行数:8,代码来源:book-store.php
示例7: isValid
public function isValid($value)
{
$this->setValue($value);
if (!timezone_open($value)) {
$this->error(self::INVALID_TIMEZONE);
return false;
}
return true;
}
开发者ID:bcremer,项目名称:mwop.net,代码行数:9,代码来源:Timezone.php
示例8: safeCreateDateTimeZone
protected static function safeCreateDateTimeZone($object)
{
if ($object instanceof \DateTimeZone) {
return $object;
}
$tz = @timezone_open((string) $object);
if ($tz === false) {
throw new \InvalidArgumentException('Unknown or bad timezone (' . $object . ')');
}
return $tz;
}
开发者ID:igez,项目名称:gaiaehr,代码行数:11,代码来源:Carbon.php
示例9: printChange
function printChange($tag, $change)
{
$output = "<tr>";
//$time = time($change["time"]);
$time = $change["time"];
$time = date_create($change["time"], timezone_open('GMT'));
//$time = date_format($time, "F j, Y \a\\t g:i a e");
$time = date_format($time, "F j, Y");
switch ($change["type"]) {
case "creation":
$output .= "<td>created statement";
$output .= "<td>in <code>" . $change["file"] . ".tex</code>";
if ($change["label"] != "") {
$output .= "<br>label <code>" . $change["label"] . "</code>";
}
$output .= "<td>" . $time;
$output .= "<td><a href='" . GitHubCommitLinesLink($change) . "'>link</a>";
break;
case "label":
$output .= "<td>changed label";
$output .= "<td>label <code>" . $change["label"] . "</code>";
$output .= "<td>" . $time;
$output .= "<td><a href='" . GitHubCommitLinesLink($change) . "'>diff</a>";
break;
case "move":
$output .= "<td>moved the tag";
$output .= "<td>";
$output .= "<td>" . $time;
break;
case "move file":
$output .= "<td>moved the tag";
$output .= "<td>to <code>" . $change["file"] . ".tex</code>";
$output .= "<td>" . $time;
break;
case "proof":
case "statement":
case "statement and proof":
$output .= "<td>changed " . $change["type"];
$output .= "<td>";
$output .= "<td>" . $time;
$output .= "<td><a href='" . GitHubDiffLink($change) . "'>diff</a>";
break;
case "tag":
$output .= "<td>assigned tag";
$output .= "<td><var>" . $tag . "</var>";
$output .= "<td>" . $time;
$output .= "<td>";
break;
}
$output .= "</tr>";
return $output;
}
开发者ID:robertcardona,项目名称:stacks-website,代码行数:52,代码来源:taghistory.php
示例10: parseInputList
function parseInputList()
{
$list = $_GET['list'];
$lines = preg_split('/\\n/', $list);
$result = [];
//var_dump($lines);
foreach ($lines as $line) {
$tempDate = date_create($line, timezone_open("Europe/Sofia"));
if ($line != "" && $tempDate) {
$result[] = $tempDate;
}
}
return $result;
}
开发者ID:KonstantinKirchev,项目名称:PHP,代码行数:14,代码来源:date-sorter.php
示例11: calculateDistance
/**
* Calculates date interval from $dateTime (given in current format) to current datetime
*
* @param string $format
* @param string $dateTime
*
* @return \DateInterval
*/
public static function calculateDistance($dateTime, $format = null)
{
if ($dateTime == '') {
return array();
}
if ($format == null) {
$format = $_SESSION['formats']['datetime_php'];
}
$date = \DateTime::createFromFormat($format, $dateTime, timezone_open('UTC'));
$now = new \DateTime('now', timezone_open('UTC'));
$interval = (array) $date->diff($now);
$interval['expired'] = $interval['invert'] == 0 ? 1 : 0;
return $interval;
}
开发者ID:barcodex,项目名称:temple,代码行数:22,代码来源:DateTimeUtil.php
示例12: 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
示例13: getStartTimeStamp
/**
* Getter for the start timestamp.
*
* @param int $index
* The index of the field value to be retrieved. Defaults to 0.
*
* @return int
* The start date as a UNIX timestamp.
*/
protected function getStartTimeStamp($index = 0)
{
$value = $this->fieldItemList->getValue()[$index]['value'];
$field_def = $this->fieldItemList->getFieldDefinition();
$field_type = $field_def->getFieldStorageDefinition()->getType();
if ($field_type == 'datetime') {
/** @var \Drupal/datetime\Plugin\FieldType\DateTimeItem $field */
$field = $this->fieldItemList->get($index);
// Set User's Timezone
$field->date->setTimezone(timezone_open(drupal_get_user_timezone()));
// Format to timestamp.
return $field->date->format('U');
}
return (int) $value;
}
开发者ID:CIGIHub,项目名称:bsia-drupal8,代码行数:24,代码来源:DateFieldWrapper.php
示例14: __construct
/**
* Creates a new timezone from a given name.
*
* @param string timezone name or NULL to use default timezone
* @throws lang.IllegalArgumentException if timezone is unknown
*/
public function __construct($tz)
{
switch (TRUE) {
case is_string($tz):
$this->tz = timezone_open($tz);
break;
case is_null($tz):
$this->tz = timezone_open(date_default_timezone_get());
break;
case $tz instanceof DateTimeZone:
$this->tz = $tz;
}
if (!$this->tz instanceof DateTimeZone) {
$e = new IllegalArgumentException('Invalid timezone identifier given: "' . $tz . '"');
xp::gc(__FILE__);
throw $e;
}
}
开发者ID:melogamepay,项目名称:xp-framework,代码行数:24,代码来源:TimeZone.class.php
示例15: printComment
function printComment($comment)
{
global $config;
$output = "";
$tag = getTag($comment['tag']);
$date = date_create($comment['date'], timezone_open('GMT'));
$output .= "<li>On " . date_format($date, 'F j') . " ";
if (empty($comment['site'])) {
$output .= htmlspecialchars($comment['author']);
} else {
$output .= "<a href='" . htmlspecialchars($comment['site']) . "'>" . htmlspecialchars($comment['author']) . "</a>";
}
$output .= " left <a href='" . href("tag/" . $comment["tag"] . "#comment-" . $comment['id']) . "'>comment " . $comment['id'] . "</a>";
$output .= " on <a href='" . href('tag/' . $comment['tag']) . "'>tag <var title='" . $tag['label'] . "'>" . $comment['tag'] . "</var></a>";
$output .= "<blockquote>";
$output .= htmlentities(substr($comment['comment'], 0, $config["comments cutoff"])) . (strlen($comment['comment']) > $config["comments cutoff"] ? '...' : '');
$output .= "</blockquote>";
return $output;
}
开发者ID:robertcardona,项目名称:stacks-website,代码行数:19,代码来源:recentcomments.php
示例16: __construct
/**
* Constructor. Creates a new date object through either a
* <ul>
* <li>integer - interpreted as timestamp</li>
* <li>string - parsed into a date</li>
* <li>php.DateTime object - will be used as is</li>
* <li>NULL - creates a date representing the current instance</li>
* </ul>
*
* Timezone assignment works through these rules:
* . If the time is given as string and contains a parseable timezone identifier
* that one is used.
* . If no timezone could be determined, the timezone given by the
* second parameter is used
* . If no timezone has been given as second parameter, the system's default
* timezone is used.
*
* @param var in default NULL either a string or a Unix timestamp or DateTime object, defaulting to now
* @param string timezone default NULL string of timezone
* @throws lang.IllegalArgumentException in case the date is unparseable
*/
public function __construct($in = null, TimeZone $timezone = null)
{
if ($in instanceof \DateTime) {
$this->date = $in;
} else {
if ((string) (int) $in === (string) $in) {
// Specially mark timestamps for parsing (we assume here that strings
// containing only digits are timestamps)
$this->date = date_create('@' . $in, timezone_open('UTC'));
date_timezone_set($this->date, $timezone ? $timezone->getHandle() : timezone_open(date_default_timezone_get()));
} else {
try {
$this->date = $timezone ? new \DateTime($in, $timezone->getHandle()) : new \DateTime($in);
} catch (\Exception $e) {
throw new IllegalArgumentException('Given argument is neither a timestamp nor a well-formed timestring: ' . \xp::stringOf($in));
}
}
}
}
开发者ID:johannes85,项目名称:core,代码行数:40,代码来源:Date.class.php
示例17: __construct
/**
* Constructor. Creates a new date object through either a
* <ul>
* <li>integer - interpreted as timestamp</li>
* <li>string - parsed into a date</li>
* <li>php.DateTime object - will be used as is</li>
* <li>NULL - creates a date representing the current instance</li>
* </ul>
*
* Timezone assignment works through these rules:
* . If the time is given as string and contains a parseable timezone identifier
* that one is used.
* . If no timezone could be determined, the timezone given by the
* second parameter is used
* . If no timezone has been given as second parameter, the system's default
* timezone is used.
*
* @param var in default NULL either a string or a Unix timestamp or DateTime object, defaulting to now
* @param string timezone default NULL string of timezone
* @throws lang.IllegalArgumentException in case the date is unparseable
*/
public function __construct($in = NULL, TimeZone $timezone = NULL)
{
if ($in instanceof DateTime) {
$this->date = $in;
} else {
if ((string) (int) $in === (string) $in) {
// Specially mark timestamps for parsing (we assume here that strings
// containing only digits are timestamps)
$this->date = date_create('@' . $in, timezone_open('UTC'));
date_timezone_set($this->date, $timezone ? $timezone->getHandle() : timezone_open(date_default_timezone_get()));
} else {
$this->date = $timezone ? date_create($in, $timezone->getHandle()) : date_create($in);
if (FALSE === $this->date || xp::errorAt(__FILE__, __LINE__ - 1)) {
$e = new IllegalArgumentException('Given argument is neither a timestamp nor a well-formed timestring: ' . xp::stringOf($in));
xp::gc(__FILE__);
throw $e;
}
}
}
}
开发者ID:melogamepay,项目名称:xp-framework,代码行数:41,代码来源:Date.class.php
示例18: __construct
/**
* Creates a new timezone from a given name.
*
* @param string timezone name or NULL to use default timezone
* @throws lang.IllegalArgumentException if timezone is unknown
*/
public function __construct($tz)
{
if (null === $tz) {
$this->tz = timezone_open(date_default_timezone_get());
} else {
if (is_string($tz)) {
try {
$this->tz = new \DateTimeZone($tz);
} catch (\Throwable $e) {
throw new IllegalArgumentException('Invalid timezone identifier given: ' . $e->getMessage());
}
} else {
if ($tz instanceof \DateTimeZone) {
$this->tz = $tz;
} else {
throw new IllegalArgumentException('Expecting NULL, a string or a DateTimeZone instance, have ' . \xp::typeOf($tz));
}
}
}
}
开发者ID:xp-framework,项目名称:core,代码行数:26,代码来源:TimeZone.class.php
示例19: setValue
/**
* Set timezone
*
* Sets the timezone value. This method accepts timezone names as strings.
* You can get the full list of accepted values in the PHP manual: {@link
* http://php.net/manual/en/timezones.php} (note, some timezones inside the
* Others are not accepted):
* <code> $tz = new AeDate_Timezone('Europe/Amsterdam');
* $date = new AeDate('2009-05-12 14:00:00', 'Europe/Moscow');
*
* echo $date; // Tue, 12 May 2009 14:00:00 +0400
* echo $date->setTimezone($tz); // Tue, 12 May 2009 12:00:00 +0200</code>
*
* @throws AeDateTimezoneException #400 on invalid value
* @throws AeDateTimezoneException #413 on unrecognized timezone identifier
*
* @param string|DateTimeZone $value
*
* @return AeDate_Timezone self
*/
public function setValue($value)
{
if ($value instanceof AeString) {
$value = $value->getValue();
}
if (!is_string($value) && !$value instanceof DateTimeZone) {
throw new AeDateTimezoneException('Invalid value passed: expecting string or DateTimeZone, ' . AeType::of($value) . ' given', 400);
}
if (!$value instanceof DateTimeZone) {
if (strpos($value, ' ') !== false) {
$value = str_replace(' ', '_', trim($value));
}
$zone = @timezone_open($value);
if (!$zone) {
throw new AeDateTimezoneException('Unrecognized timezone identifier: ' . $value, 413);
}
$value = $zone;
}
$this->_value = $value;
return $this;
}
开发者ID:jvirtism,项目名称:AnEngine,代码行数:41,代码来源:timezone.class.php
示例20: __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
注:本文中的timezone_open函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论