我希望我的页面能够针对用户查看进行个性化,并且需要一些帮助来查找他们的经度和纬度,而不是将其设置为英国柴郡。
<?php
$info = date_sun_info(mktime(0,0,0), 53.3761, -2.1897); // Cheshire UK
$rise = new datetime(date('Y-m-d H:i:s', $info['sunrise']));
$set = new datetime(date('Y-m-d H:i:s', $info['sunset']));
list($daylightHrs, $daylightMins) = explode(':', $set->diff($rise)->format('%h:%i'));
list($elapsedHrs, $elapsedMins) = explode(':', $rise->diff(new DateTime())->format('%h:%i'));
$daylight = $daylightHrs*60 + $daylightMins;
$elapsed = $elapsedHrs*60 + $elapsedMins;
$percent = $elapsed*100/$daylight;
printf('Rises: %s<br>Sets: %s<br>Day length: %d minutes<br>Day elapsed: %d minutes (%d%%)',
$rise->format('H:i'),
$set->format('H:i'),
$daylight,
$elapsed,
$percent
);
?>
有人可以帮忙吗?我希望该页面能够告诉用户日出和日落,无论他们身在何处。