Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

date_sun_info()

Example

Retrieve information about sunrise, sunset, and twilight begin/end for January 1, 2013, at latitude 31.7667 and longitude 35.2333.

<?php
$sun_info=date_sun_info(strtotime(“2013-01-01”),31.7667,35.2333);
foreach ($sun_info as $key=>$val)
  {
  echo “$key: “ . date(“H:i:s”,$val) . “<br>”;
  }
?>

Definition and Usage

The date_sun_info() function returns an array with information about sunset, sunrise, and twilight begin/end for a given day and location.

Tip: Use the date_sunrise() function to get the sunrise time for a specific day and location.

 

Tip: Use the date_sunset() function to get the sunset time for a specific day and location.

Syntax

date_sun_info(timestamp, latitude, longitude)

Parameter Values

 

Parameter

Description

timestamp

Required. Specifies a timestamp.

latitude

Required. Specifies the latitude in degrees.

longitude

Required. Specifies the longitude in degrees.

Technical Details

Return Value:

Returns an array on success; FALSE on failure.

PHP Version:

5.1.2+