Calculating Timezone and DST offset
-
Hello,
I am trying to work out how I can calculate day light saving time, after I have worked out the timezone. For example. $timezone = 0, when I put in the longitude and latitude of Cambridge in the United Kingdom. This is as expected. But, I want to write a code so it also takes into account daylight saving time. On the 30th July 1985, I would expect an overall output ($time) of 1, as that is the summer time daylight saving adjustment.
I cannot see why the code below wont work, any ideas ? I am sure the rawoffset command is meant to make the adjustment.
<?php $town = urldecode($_GET['town']); $country = urldecode($_GET['country']); $location = json_decode(@file_get_contents('https://maps.googleapis.com/maps/api/geocode/json?key=API_KEY_HERE&address='.urlencode($town.', '.(!empty($state) ? $state.', ' : '').$country)), true)['results'][0]['geometry']['location']; $timezone = json_decode(@file_get_contents('https://maps.googleapis.com/maps/api/timezone/json?key=API_KEY_HERE&location='.$location['lat'].','.$location['lng'].'×tamp='.date('U')), true); $time = $timezone['rawOffset'] / 60 / 60; echo $time;
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Calculating Timezone and DST offset’ is closed to new replies.