get_sunset() problems

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
heritage
Forum Newbie
Posts: 2
Joined: Thu Oct 25, 2007 1:21 pm

get_sunset() problems

Post by heritage »

I am trying to use get_sunset function and having the following problems:

1. why when I use time() parameter it shows different result then when I use date('Y-m-d') ? Shouldn't sunset be the same time during the whole day??

2. I took the information for chicago from the reliable chart: $lat = 41.9897; $lng = -87.7014; but it doesn't show me the same result. I mean the minutes part is wrong, so offset has nothing to do with it. For example 2007-10-25 sunset should be 17:55, but I cannot get such time.

3. I tried using different zenith, but doesn't help.



Any ideas?
User avatar
churt
Forum Commoner
Posts: 39
Joined: Wed Oct 04, 2006 9:59 am

function or class

Post by churt »

Are you perhaps referring to date_sunset?
heritage
Forum Newbie
Posts: 2
Joined: Thu Oct 25, 2007 1:21 pm

Post by heritage »

yes, you are right.
the rest of the message is correct :(
User avatar
churt
Forum Commoner
Posts: 39
Joined: Wed Oct 04, 2006 9:59 am

Weekend

Post by churt »

Sorry I did not get back sooner. Went on vacation and had no access to play with code.

It gets tricky using a date but just make sure that you preface all date references with strtotime().

This code worked fine for me.

Code: Select all

echo date_sunset(strtotime('2007-10-25 10:01'), SUNFUNCS_RET_STRING, 41.98, -87.90,90.83,-5);
When I use 41.9897 and -87.7014 I get 17:54. I could live with that but the ones I used above give me 17:55. I took them from Chicago/O'hare,IL.

I had issues using

Code: Select all

date('Y-m-d', '2007-10-25')
When I used

Code: Select all

strtotime(date('Y-m-d', strtotime('2007-10-25'))
it worked fine.

I then realized that was redundant and shortened it to

Code: Select all

strtotime('2007-10-25')
Hope this helps.
Post Reply