To expand a bit on why the localtime() is not enough, two factors are at play. First, the solar noon can be as much as two hours displaced from the timezone. This is basically time zone vs longitude. Second, depending on time of year and attitude you can go from having no daylight in the winter to no darkness in the summer.<p>Solar noon details here: <a href="http:&#x2F;&#x2F;blog.poormansmath.net&#x2F;images&#x2F;SolarTimeVsStandardTimeV2.png" rel="nofollow">http:&#x2F;&#x2F;blog.poormansmath.net&#x2F;images&#x2F;SolarTimeVsStandardTimeV...</a>