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


PHP date_sunrise函数代码示例

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


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

示例1: data

 function data($msg, $params)
 {
     $arg = funcs::utfToAscii($msg->args);
     if (empty($arg)) {
         $data = time();
     } else {
         $data = calendar::parse_date($arg);
         if (!$data) {
             return new BotMsg('Podana data nie została rozpoznana<br />' . "\n" . '<br />' . "\n" . '<u>Przykłady:</u><br />' . "\n" . 'data<br />' . "\n" . 'data pojutrze<br />' . "\n" . 'data 1.01.2009');
         }
     }
     if (date('d.m.Y') == date('d.m.Y', $data)) {
         $txt = 'Dziś jest ';
     } else {
         $txt = 'Wybrany dzień to ';
     }
     include './data/data/data.php';
     $txt .= self::$dni[date('w', $data)] . ', ' . date('j', $data) . ' ' . self::$miesiace[date('n', $data)] . ' ' . date('Y', $data) . ' r., ' . (date('z', $data) + 1) . ' dzień roku.<br />' . "\n" . '<br />' . "\n";
     $msg->session->setClass('pogoda');
     if (!isset($msg->session->geo)) {
         $geo = array('lon' => '52.25', 'lat' => '21.0');
     } else {
         $geo = $msg->session->geo;
     }
     $txt .= 'Imieniny: ' . $imieniny[date('n', $data)][date('j', $data)] . '<br />' . "\n" . 'Wschód Słońca: ' . date_sunrise($data, SUNFUNCS_RET_STRING, $geo['lat'], $geo['lon'], 90.58, 1 + date('I')) . '<br />' . "\n" . 'Zachód Słońca: ' . date_sunset($data, SUNFUNCS_RET_STRING, $geo['lat'], $geo['lon'], 90.58, 1 + date('I'));
     return new BotMsg($txt);
 }
开发者ID:Alambos,项目名称:bot,代码行数:27,代码来源:handler.php

示例2: hora

function hora()
{
    echo "Amanecer: ";
    echo date_sunrise(time()) . "<br>";
    echo "Atardecer: ";
    echo date_sunset(time());
}
开发者ID:a13YasminCP,项目名称:www.yasmincp.local,代码行数:7,代码来源:funciones.php

示例3: getSunriseTime

 /**
  * Returns sunrise time
  * @param float $latitude
  * @param float $longitude
  * @param null|int $timestamp If not set, current timestamp will be used.
  * @param null|int $gmtOffset If not set, current GMT offset will be used.
  * @static
  * @return string
  */
 public static function getSunriseTime($latitude, $longitude, $timestamp = null, $gmtOffset = null)
 {
     $timestamp = self::checkTimestamp($timestamp);
     if (!$gmtOffset) {
         $gmtOffset = self::getGmtOffset();
     }
     return date_sunrise($timestamp, SUNFUNCS_RET_STRING, $latitude, $longitude, ini_get('date.sunrise_zenith'), $gmtOffset);
 }
开发者ID:buzzboard,项目名称:buzzboard-php-sdk,代码行数:17,代码来源:Time.php

示例4: getSunrise

function getSunrise($m = true)
{
    $d = date_sunrise(time(), SUNFUNCS_RET_TIMESTAMP, $GLOBALS['config']['geo']['lat'], $GLOBALS['config']['geo']['long'], $GLOBALS['config']['geo']['zenith'], timeZoneOffset());
    if ($m) {
        $d = dateToMinutes($d);
    }
    return $d;
}
开发者ID:bangnaga,项目名称:HomeOverlord,代码行数:8,代码来源:h2ha.php

示例5: sunriseAndSunsetAction

 /**
  * @Route("/vychod-a-zapad-slunce/{when}", name="sunrise_and_sunset", defaults={"when"="0"}, requirements={"when"="\d+"})
  * @Template()
  */
 public function sunriseAndSunsetAction($when)
 {
     $date = new \DateTime();
     $date->add(new \DateInterval("P" . $when . "D"));
     date_default_timezone_set("Europe/Prague");
     $sunrise = date_sunrise($date->getTimestamp(), SUNFUNCS_RET_STRING, 50.0872, 14.4211);
     $sunset = date_sunset($date->getTimestamp(), SUNFUNCS_RET_STRING, 50.0872, 14.4211);
     return ['sunrise' => $sunrise, 'sunset' => $sunset, 'date' => $date];
 }
开发者ID:Symfonisti,项目名称:micro-kernel,代码行数:13,代码来源:DefaultController.php

示例6: sunrise

 /**
  * @param float $latitude
  * @param float $longitude
  * @param int $zenith
  * @param int $gmt
  * @return Sunrise
  * Defaults to Perth, Western Australia
  */
 public static function sunrise($selection = 'perth', $zenith = 90 + 50 / 60)
 {
     $latitude = self::$coordinates[$selection][0];
     $longitude = self::$coordinates[$selection][1];
     $gmt = self::$coordinates[$selection][2];
     $sunrise = date_sunrise(time(), SUNFUNCS_RET_STRING, $latitude, $longitude, $zenith, $gmt);
     $sunset = date_sunset(time(), SUNFUNCS_RET_STRING, $latitude, $longitude, $zenith, $gmt);
     return new Sunrise($latitude, $longitude, $zenith, $gmt, "Perth", $sunrise, $sunset);
 }
开发者ID:squaredcircle,项目名称:GroupBot,代码行数:17,代码来源:Weather.php

示例7: setFrom

 /**
  * @param int $timestamp
  * @param \League\Geotools\Coordinate\CoordinateInterface $coordinate
  * @param int $offset
  * @return \Runalyze\Calculation\NightDetector $this-reference
  * @throws \InvalidArgumentException
  */
 public function setFrom($timestamp, CoordinateInterface $coordinate, $offset = 0)
 {
     if (!is_numeric($timestamp)) {
         throw new \InvalidArgumentException('Provided timestamp must be numerical.');
     }
     $isAfterSunset = $timestamp > date_sunset($timestamp, SUNFUNCS_RET_TIMESTAMP, $coordinate->getLatitude(), $coordinate->getLongitude(), self::ZENITH, $offset);
     $isBeforeSunrise = $timestamp < date_sunrise($timestamp, SUNFUNCS_RET_TIMESTAMP, $coordinate->getLatitude(), $coordinate->getLongitude(), self::ZENITH, $offset);
     $this->Value = $isAfterSunset || $isBeforeSunrise;
     return $this;
 }
开发者ID:rob-st,项目名称:Runalyze,代码行数:17,代码来源:NightDetector.php

示例8: zeroPowerYesterday

/**
 * Function to highlight when a generation meter has power readings of zero
 * over the last day despite decent sol_rad figures (>DECENT_SOLRAD_LIMIT W/m2).
 * It looks at each half-hourly measurement.
 *
 * @param resource $becDB
 * @return boolean TRUE if any unexpected zero generation periods seen
 */
function zeroPowerYesterday(&$becDB)
{
    global $verbose, $graphsEnabled;
    // TODO: Tune this value to remove false hits; we wouldn't expect any power
    // output when it's really dim...
    define('DECENT_SOLRAD_LIMIT', 30);
    $dateTime = getYesterdayDateTime();
    $sql = "SELECT power.*,\n                   weather_filton.sol_rad AS sol_rad_filton,\n                   create_centre_meteo_raw.sol_rad AS sol_rad_cc\n            FROM power\n                LEFT JOIN weather_filton ON power.datetime = weather_filton.datetime\n                LEFT JOIN create_centre_meteo_raw ON power.datetime = create_centre_meteo_raw.datetime\n            WHERE (weather_filton.sol_rad > " . DECENT_SOLRAD_LIMIT . " OR\n                  create_centre_meteo_raw.sol_rad > " . DECENT_SOLRAD_LIMIT . ") AND\n                  DATE(power.datetime) = " . sqlDateString($dateTime);
    $result = $becDB->fetchQuery($sql);
    // Work out when sunrise and sunset are - we'll ignore any zero power readings close to them
    $timestamp = $dateTime->getTimestamp();
    $sunriseTime = date_sunrise($timestamp, SUNFUNCS_RET_TIMESTAMP, FORECAST_IO_LAT, FORECAST_IO_LONG);
    $sunsetTime = date_sunset($timestamp, SUNFUNCS_RET_TIMESTAMP, FORECAST_IO_LAT, FORECAST_IO_LONG);
    $ignoreWithin = 60 * 60;
    // One hour
    $anyHits = FALSE;
    foreach ($result as $entry) {
        $zeroMeterCount = 0;
        foreach ($becDB->getGenMeterArray() as $genMeter) {
            $dateTime = new DateTime($entry['datetime']);
            $timestamp = $dateTime->getTimestamp();
            # Note: The === below is necessary as otherwise NULL/uninitialised data would also match
            if ($entry[$genMeter] === 0 && $timestamp > $sunriseTime + $ignoreWithin && $timestamp < $sunsetTime - $ignoreWithin) {
                if (!$anyHits) {
                    $anyHits = TRUE;
                    ReportLog::append('Unexpected zero power output during ' . $dateTime->format('d/m/Y') . ":\n");
                    ReportLog::setError(TRUE);
                }
                if ($zeroMeterCount == 0) {
                    ReportLog::append('  Period ending [' . $dateTime->format('H:i') . " (UTC)]\tSolar radiation [CC: " . $entry['sol_rad_cc'] . ' Filton: ' . $entry['sol_rad_filton'] . "]: {$genMeter}");
                    $zeroMeterCount++;
                } else {
                    ReportLog::append(', ' . $genMeter);
                    $zeroMeterCount++;
                }
            }
        }
        if ($zeroMeterCount) {
            ReportLog::append("\n");
        }
    }
    if ($anyHits) {
        ReportLog::append("\n\n");
    } else {
        ReportLog::append('No unexpected zero power output readings yesterday (' . $dateTime->format('d/m/Y') . ")\n\n");
    }
    return $anyHits;
}
开发者ID:bec-uk,项目名称:bec_fault_mon,代码行数:56,代码来源:analysis.php

示例9: isOpen

 /**
  * Return true, false or null depending on whether the [opening hours]
  * value explicitly indicates an open, closed or undecided result.
  *
  * @param double $time A numeric value representing a time. If null, the
  *                     current time is used.
  *
  * @link   http://wiki.openstreetmap.org/wiki/Key:opening_hours
  * @return null|boolean
  */
 public function isOpen($time = null)
 {
     if ($this->value === null) {
         return null;
     }
     if ($this->value === '24/7') {
         return true;
     }
     if ($time === null) {
         $time = time();
     }
     if ($this->value === 'sunrise-sunset') {
         $start = $this->_startTime(date_sunrise($time));
         $end = $this->_endTime(date_sunset($time));
         $d = getdate($time);
         $ctime = $d['hours'] * 60 + $d['minutes'];
         return $ctime >= $start && $ctime <= $end;
     }
     // other simple test would be sunrise-sunset - with
     // offsets that would need to be taken into account
     // time specs...
     $rule_sequences = explode(';', $this->value);
     $day = strtolower(substr(date('D', $time), 0, 2));
     $retval = false;
     foreach ($rule_sequences as $rule_sequence) {
         $rule_sequence = strtolower(trim($rule_sequence));
         // If the day is explicitly specified in the rule sequence then
         // processing it takes precedence.
         if (preg_match('/' . $day . '/', $rule_sequence)) {
             // @fixme: brittle. use preg_replace with \w
             $portions = explode(' ', str_replace(', ', ',', $rule_sequence));
             return $this->_openTimeSpec($portions, $time);
         }
         // @fixme: brittle. use preg_replace with \w
         $portions = explode(' ', str_replace(', ', ',', $rule_sequence));
         $open = $this->_openTimeSpec($portions, $time);
         if ($open) {
             $retval = true;
         } elseif ($open === false) {
             $retval = false;
         }
     }
     return $retval;
 }
开发者ID:AndrOrt,项目名称:Services_Openstreetmap,代码行数:54,代码来源:OpeningHours.php

示例10: _sunny

 private static function _sunny($lat, $lng, $timezone)
 {
     // Get the beginning of the current day
     $now = new DateTime();
     if ($timezone) {
         $now->setTimeZone(new DateTimeZone($timezone));
     }
     $now->setTime(0, 0, 0);
     $now = $now->format('U');
     if ($lat !== null) {
         $sunrise = date_sunrise($now, SUNFUNCS_RET_TIMESTAMP, $lat, $lng, 96);
         $sunset = date_sunset($now, SUNFUNCS_RET_TIMESTAMP, $lat, $lng, 92);
         if ($sunrise < time() && time() < $sunset) {
             return 'day';
         } else {
             return 'night';
         }
     } else {
         return 'unknown';
     }
 }
开发者ID:aaronpk,项目名称:Atlas,代码行数:21,代码来源:Weather.php

示例11: getForecast

 public function getForecast($latitude, $longitude, $units)
 {
     $response = array("response_message" => array("type" => "RESPONSE", "name" => "WEATHER_FORECAST", "data" => array()));
     $url = self::API_ENDPOINT . self::API_KEY . '/';
     $url .= $latitude . ',' . $longitude . '?units=' . $units;
     $forecast = file_get_contents($url);
     //print_r($http_response_header);
     if (isset($http_response_header) && strpos($http_response_header[0], '200')) {
         $forecast = (array) json_decode($forecast, true);
         $time = $forecast["currently"]["time"];
         //timestamp del a salida del sol.
         $sunrise_timestamp = date_sunrise($time, SUNFUNCS_RET_TIMESTAMP, $forecast['latitude'], $forecast['longitude']);
         $sunset_timestamp = date_sunset($time, SUNFUNCS_RET_TIMESTAMP, $forecast['latitude'], $forecast['longitude']);
         //print_r($forecast);
         $forecast['currently']['sunrise_timestamp'] = $sunrise_timestamp;
         $forecast['currently']['sunset_timestamp'] = $sunset_timestamp;
         $response["response_message"]["data"] = array("error" => false, "msg" => array("forecast" => $forecast));
     } else {
         $response["response_message"]["data"] = array("error" => true, "msg" => array("msg" => "La previsión no se pudo obtener"));
     }
     return $response;
 }
开发者ID:sergio11,项目名称:teVeo,代码行数:22,代码来源:weatherController.php

示例12: __construct

 /**
  * @param hcal_datetime $dt
  */
 public function __construct($dt)
 {
     $this->datetime = $dt;
     // $heb_date, $ts, $gmt_offset, $location, $now, $datetime =  null
     $ts = $dt->get_ts(false);
     $this->is_dst = false;
     $tz_offset = $dt->get_timezone_offset($this->is_dst);
     $ts -= $tz_offset;
     $this->gmt_offset = $tz_offset / 3600.0;
     $this->now = $dt->s / 3600.0 + $dt->m / 60.0 + $dt->h;
     $zenith = 90.0 + 50.0 / 60;
     $this->heb_date = $dt->get_hebrew_date_numeric();
     $this->location = $dt->location;
     $this->data = array();
     $lat = $this->location->latitude;
     $long = $this->location->longitude;
     $sunrise = date_sunrise($ts, SUNFUNCS_RET_DOUBLE, $lat, $long, $zenith, $this->gmt_offset);
     $sunset = date_sunset($ts, SUNFUNCS_RET_DOUBLE, $lat, $long, $zenith, $this->gmt_offset);
     $this->sunrise = $sunrise;
     $this->sunset = $sunset;
     $this->rel_hr = ($sunset - $sunrise) / 12.0;
     $this->is_chul = (bool) @$this->location->data['chul'];
     $this->calculate_base_times();
 }
开发者ID:laiello,项目名称:pkgmanager,代码行数:27,代码来源:halachic_times.class.php

示例13: realpath

<?php

$taskLocation = realpath(dirname(__FILE__));
chdir($taskLocation);
include "../config.php";
$meteogram = array('location' => array('name' => 'Scampton', 'type' => 'Town', 'country' => "United Kingdom", 'timezone' => array('@attributes' => array('id' => "Europe/London", 'utcoffsetMinutes' => "0")), 'location' => array('@attributes' => array('altitude' => "", 'latitude' => "", 'longitude' => "", 'geobase' => "geonames", 'geobaseid' => "2643743"))), 'credit' => array('comment' => array("", ""), 'link' => array("@attributes" => array("text" => "Weather forecast from yr.no, delivered by the Norwegian Meteorological Institute and the NRK", "url" => "http://www.yr.no/place/United_Kingdom/England/London/"))), 'links' => array('link' => array(array('@attributes' => array('id' => "xmlSource", 'url' => "http://www.yr.no/place/United_Kingdom/England/London/forecast.xml")), array('@attributes' => array('id' => "xmlSourceHourByHour", 'url' => "http://www.yr.no/place/United_Kingdom/England/London/forecast_hour_by_hour.xml")), array('@attributes' => array('id' => "hourByHour", 'url' => "http://www.yr.no/place/United_Kingdom/England/London/hour_by_hour")), array('@attributes' => array('id' => "overview", 'url' => "http://www.yr.no/place/United_Kingdom/England/London/")), array('@attributes' => array('id' => "longTermForecast", 'url' => "http://www.yr.no/place/United_Kingdom/England/London/long")))), 'meta' => array('lastupdate' => "", 'nextupdate' => ""), 'sun' => array("@attributes" => array('rise' => "", 'set' => "")), 'forecast' => array('tabular' => array('time' => array())));
date_default_timezone_set(TZ);
if (date('I')) {
    $meteogram['location']['timezone']['@attributes']['utcoffsetMinutes'] = "60";
}
$meteogram['meta']['lastupdate'] = Date("Y-m-d\\TH:m:s");
$meteogram['meta']['nextupdate'] = Date("Y-m-d\\TH:m:s");
$meteogram['sun']['@attributes']['rise'] = Date("Y-m-d") . "T" . date_sunrise(time(), SUNFUNCS_RET_STRING, LAT, LONG, 90 + 60 / 60, 0);
$meteogram['sun']['@attributes']['set'] = Date("Y-m-d") . "T" . date_sunset(time(), SUNFUNCS_RET_STRING, LAT, LONG, 90, 0);
$meteogram['location']['location']['@attributes']['altitude'] = ALTITUDE;
$meteogram['location']['location']['@attributes']['latitude'] = LAT;
$meteogram['location']['location']['@attributes']['longitude'] = LONG;
//die($meteogram['location']['timezone'] ['@attributes']);
$meteogram['location']['timezone']['@attributes']['id'] = TZ;
$link = mysql_connect(SERVER, USER, PASSWORD);
$db_found = mysql_select_db(DATABASE);
$sql = "SELECT * FROM Weather.meteogram " . "WHERE `from` >= now() - INTERVAL 49 HOUR GROUP BY DATE_FORMAT(`from`, \"%d-%m-%y %H:00\");";
$query = mysql_query($sql);
$tabularContent = "";
$time = array(['@attributes'] => array(['from'] => "0", ['to'] => "0"), ['comment'] => array(), ['symbol'] => array(['@attributes'] => array(['number'] => "2", ['numberEx'] => "02", ['name'] => "Fair", ['var'] => "02d")), ['precipitation'] => array(['@attributes'] => array(['value'] => "0")), ['windDirection'] => array(['@attributes'] => array(['deg'] => "0", ['code'] => "0", ['name'] => "0")), ['windSpeed'] => array(['@attributes'] => array(['mps'] => "0", ['name'] => "")), ['temperature'] => array(['@attributes'] => array(['unit'] => "celcius", ['value'] => "0")), ['pressure'] => array(['@attributes'] => array(['unit'] => "hPa", ['value'] => "0")));
while ($r = mysql_fetch_array($query)) {
    $time['@attributes']['from'] = $r['from'];
    $time['@attributes']['to'] = $r['to'];
    $time['comment'] = array("", "");
    $time['symbol']['@attributes']['number'] = "";
    $time['symbol']['@attributes']['numberEx'] = "";
开发者ID:JonnyHonda,项目名称:SimpleWeatherStation,代码行数:31,代码来源:meteogram-json.php

示例14: date_default_timezone_set

	<h1>When should Marty hunt?</h1>
	

	<?php 
/* calculate the sunrise time for Lisbon, Portugal
	 Latitude: 47.4736 North
	 Longitude: 94.8803 West
	 Zenith ~= 90
	 timezone: GMT -06
	 */
date_default_timezone_set('America/Chicago');
//print "Today is ";
//print date("D, M j G:i:s T Y");
print "<br />Current Time is: ";
print date("g:i A");
//print "Sunrei"
//print date_sunrise( time(), SUNFUNCS_RET_STRING,47.4736,94.8803,90,-06);
print "<br />Sunrise time : ";
print date("g: i A", date_sunrise(time(), SUNFUNCS_RET_TIMESTAMP, 47.4736, -94.88030000000001, 90, -06));
print "<br /> Start Hunting at: ";
print date("g:i A", date_sunrise(time(), SUNFUNCS_RET_TIMESTAMP, 47.4736, -94.88030000000001, 90, -06) - 1800);
print "<br/> Sunset Time: ";
print date("g:i A", date_sunset(time(), SUNFUNCS_RET_TIMESTAMP, 47.4736, -94.88030000000001, 90, -6));
print "<br/> Stop hunting at: ";
print date("g:i A", date_sunset(time(), SUNFUNCS_RET_TIMESTAMP, 47.4736, -94.88030000000001, 90, -6) + 1800);
?>
	
</body>

</html>
开发者ID:spprichard,项目名称:pric3ste,代码行数:30,代码来源:huntingTimes.php

示例15: getSunrise

function getSunrise($format)
{
    global $schedulePars;
    return date_sunrise(time(), $format, $schedulePars[SCHEDULE_LATITUDE], $schedulePars[SCHEDULE_LONGTITUDE], SCHEDULE_ZENITH, getTimeOffset());
}
开发者ID:ElectroByt,项目名称:RPi_Cam_Web_Interface,代码行数:5,代码来源:schedule.php


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