百科狗-知识改变命运!
--

date_sunset() - php 日期时间函数

是丫丫呀1年前 (2023-11-21)阅读数 15#技术干货
文章标签时间

date_sunset()

(PHP 5, PHP 7)

返回给定的日期与地点的日落时间

说明

date_sunset(int $timestamp[,int $format= SUNFUNCS_RET_STRING[,float $latitude= ini_get("date.default_latitude")[,float $longitude= ini_get("date.default_longitude")[,float $zenith= ini_get("date.sunset_zenith")[,float $gmt_offset= 0]]]]]): mixed

date_sunset() - php 日期时间函数

date_sunset()返回给定的日期(以$timestamp指定)与地点的日落时间。

参数

$timestamp

返回给定的日期(以$timestamp指定)的日落时间。

$format$format常量
常量说明取值举例
SUNFUNCS_RET_STRING以string格式返回结果16:46
SUNFUNCS_RET_DOUBLE以float格式返回结果16.78243132
SUNFUNCS_RET_TIMESTAMP以integer格式(时间戳)返回结果1095034606
$latitude

默认是指北纬。因此如果要指定南纬,必须传递一个负值。参见:date.default_latitude

$longitude

默认是指东经。因此如果要指定西经,必须传递一个负值。参见:date.default_longitude

$zenith

默认:date.sunset_zenith

$gmtoffset

单位是小时。

错误/异常

在每次调用日期/时间函数时,如果时区无效则会引发E_NOTICE错误,如果使用系统设定值或TZ环境变量,则会引发E_STRICTE_WARNING消息。参见date_default_timezone_set()。

更新日志

版本说明
5.1.0

现在发布E_STRICTE_NOTICE时区错误。

返回值

用指定的格式$format返回日落时间,或者在失败时返回FALSE

范例

Example #1date_sunset()例子

以上例程的输出类似于:

Mon Dec 20 2004, sunset time : 18:13

参见

  • date_sunrise() 返回给定的日期与地点的日出时间
yes SUNFUNCS_RET_TIMESTAMP does return GMT(0) time
so something like...
$arr = localtime(date_sunset(time(),SUNFUNCS_RET_TIMESTAMP,51.5,0)); // London
$hh = $arr[2];
$mm = $arr[1];
Will give figure out your localtime and daylight saving (BST)
maybe I am wrong, but I think
SUNFUNCS_RET_TIMESTAMP   return GMT(0) time
SUNFUNCS_RET_STRING   Return local time
SUNFUNCS_RET_DOUBLE   Return local time
I use an IP to location database to determine the visitor's approximate latitude and longitude and then serve them a day or night color scheme based on whether it is before civil dawn or dusk. I've had problems when not specifying the timezone, specifically a 1 hour error, so I use GMT. 

鹏仔微信 15129739599 鹏仔QQ344225443 鹏仔前端 pjxi.com 共享博客 sharedbk.com

免责声明:我们致力于保护作者版权,注重分享,当前被刊用文章因无法核实真实出处,未能及时与作者取得联系,或有版权异议的,请联系管理员,我们会立即处理! 部分文章是来自自研大数据AI进行生成,内容摘自(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供学习参考,不准确地方联系删除处理!邮箱:344225443@qq.com)

图片声明:本站部分配图来自网络。本站只作为美观性配图使用,无任何非法侵犯第三方意图,一切解释权归图片著作权方,本站不承担任何责任。如有恶意碰瓷者,必当奉陪到底严惩不贷!

内容声明:本文中引用的各种信息及资料(包括但不限于文字、数据、图表及超链接等)均来源于该信息及资料的相关主体(包括但不限于公司、媒体、协会等机构)的官方网站或公开发表的信息。部分内容参考包括:(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供参考使用,不准确地方联系删除处理!本站为非盈利性质站点,本着为中国教育事业出一份力,发布内容不收取任何费用也不接任何广告!)