• PHP Video Tutorials

PHP - Function date_sunset()



Syntax

mixed date_sunset ( int $timestamp [, int $format [, float $latitude 
   [, float $longitude [, float $zenith [, float $gmt_offset]]]]] )

Definition and Usage

This function returns the sunset time for a given day (specified as a timestamp) and location.

Parameters

Sr.No Parameter & Description
1

timestamp(Required)

The timestamp of the day from which the sunrise time is taken.

2

format(Optional)

It specifies how to return the result −

  • SUNFUNCS_RET_STRING (returns the result as string. e.g. 16:46)
  • SUNFUNCS_RET_DOUBLE (returns the result as float. e.g. 16.78243132)
  • SUNFUNCS_RET_TIMESTAMP (returns the result as integer (timestamp). e.g. 1095034606)
3

latitude(Optional)

It specifies the latitude of the location. The latitude defaults to North. If you want to specify a South value, you must pass a negative value.

4

longitude(Optional)

Specifies the longitude of the location. The longitude defaults to East. If you want to specify a West value, you must pass a negative value.

5

zenith

Optional.

6

gmt_offset

Optional. Specifies the difference between GMT and local time in hours.

Return Value

It returns the sunrise time in a specified format on success, or FALSE on failure.

Example

Following is the usage of this function −

<?php
   echo("Date: " . date("D M d Y") . "<br />");
   echo("Sunrise time: ");
   echo(date_sunset(time(),SUNFUNCS_RET_STRING,38.4,-9,90,1));
?> 

This will produce the following result −

Date: Wed Dec 07 2016
Sunrise time: 18:11
php_function_reference.htm
Advertisements