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


PHP date_sunset函数代码示例

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


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

示例1: hora

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

示例2: 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

示例3: local_sunset_for_date

/**
 * Calculate local sunset time for a timestamp, using system-wide location.
 */
function local_sunset_for_date($date)
{
    if (!is_numeric($date)) {
        $date = strtotime($date);
    }
    /*
     * value of 90 degrees 50 minutes is the angle at which
     * the sun is below the horizon.  This is the official
     * sunset time.  Do not use "civil twilight" zenith
     * value of 96 degrees. It's normally about 30 minutes
     * later in the evening than official sunset, and there
     * is some light until then, but it's too dark for safe
     * play.
     */
    $zenith = 90 + 50 / 60;
    /* TODO: eventually, use field's actual location rather than a
     *       system-wide location?  This would be more correct in cities
     *       with a large east/west spread, but might be confusing to some
     */
    $lat = (double) Configure::read('organization.latitude');
    $long = (double) Configure::read('organization.longitude');
    $end_timestamp = date_sunset($date, SUNFUNCS_RET_TIMESTAMP, $lat, $long, $zenith, date('Z') / 3600);
    // Round down to nearest 5 minutes, and adjust for server location
    $end_timestamp = floor($end_timestamp / 300) * 300 - Configure::read('timezone.adjust') * 60;
    return date('H:i:s', $end_timestamp);
}
开发者ID:roboshed,项目名称:Zuluru,代码行数:29,代码来源:zuluru.php

示例4: getSunset

function getSunset($m = true)
{
    $d = date_sunset(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: getSunset

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

示例14: print_r

// if ( isset($debug) ) {
if ($debug) {
    echo "dateTimeUTC: ";
    print_r($dateTimeUTC);
    //	echo "something: $something\n";
    echo "dateOff: {$dateOff}\n";
}
//offical = 90 degrees 50' 90.8333 (gk: this is the "official" number to determine sunrise & sunset)
//civil = 96 degrees (gk: this is the number to obtain civilian twilight times - horizon may be visible)
//nautical = 102 degrees (gk: this is the number to obtain nautical twilight - the horizon is not visible)
//astronomical = 108 degrees (gk: this is the number for astronomical twilight - starts at sunset).
//$zenith = 108;
// Higher is sooner sunrise
//$zenithRise = 96;
$zenithRise = 102;
// Higher is later sunset
//$zenithSet = 96;
$zenithSet = 102;
$sunrise = date_sunrise($now, SUNFUNCS_RET_TIMESTAMP, $lat, $lon, $zenithRise, $hours);
$sunset = date_sunset($now, SUNFUNCS_RET_TIMESTAMP, $lat, $lon, $zenithSet, $hours);
echo "Sunrise: " . $sunrise . "\n";
echo "Sunset: " . $sunset . "\n";
if (isset($doPretty)) {
    $nowPretty = date('Y-m-d g:i:sa', $now);
    $sunrisePretty = date('Y-m-d g:i:sa', $sunrise);
    $sunsetPretty = date('Y-m-d g:i:sa', $sunset);
    echo "now: {$now}\n";
    echo "nowPretty: {$nowPretty}\n";
    echo "sunrisePretty: {$sunrisePretty}\n";
    echo "sunsetPretty: {$sunsetPretty}\n";
}
开发者ID:mpalermo73,项目名称:scripts-git,代码行数:31,代码来源:phprisenset_tz.php

示例15: 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


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