The Google timezone API is displaying an inaccurate daylight saving offset

London now has an additional +1 hour of daylight saving time. I made a request to the Google timezone API for the London timezone, but unfortunately, it is not displaying the correct time.

https://maps.googleapis.com/maps/api/timezone/json?location=51.5072,-0.1275&timestamp=1331766000&key=[API_KEY]

The result returned by this query is as follows:

{
   "dstOffset" : 0,
   "rawOffset" : 0,
   "status" : "OK",
   "timeZoneId" : "Europe/London",
   "timeZoneName" : "Greenwich Mean Time"
}

Shouldn't the dstOffset be 3600 instead of 0??

I referred to the guidelines provided in Timezone documentation.

What could be causing this discrepancy? How can I retrieve the timezone information with accuracy regarding daylight saving time?

Answer №1

The timestamp provided (1331766000) corresponds to March 14, 2012 at 23:00:00 GMT, which likely did not have daylight saving time in effect (it typically starts on the last Sunday in March).

The correct value should be in seconds since January 1, 1970 at 00:00:00 UTC, which you can calculate using Date.now()/1000 since JavaScript time values are measured in milliseconds since the same epoch. For a specific date and time like June 24, 2014 at 13:15:34 UTC, the corresponding timestamp is 1403615734. Using this timestamp would result in the following:

{
   "dstOffset" : 3600,
   "rawOffset" : 0,
   "status" : "OK",
   "timeZoneId" : "Europe/London",
   "timeZoneName" : "British Summer Time"
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Incorporate the feedback received from the user in the previous trial as a prompt for the next

I am currently working on developing an experiment using the JSPsych JavaScript package. The main goal of my experiment is for participants to input a letter in a survey-text trial, and then have that same letter presented back to them as a stimulus in the ...

trouble encountered while parsing JSON information using JavaScript

[ [ { "Id": 1234, "PersonId": 1, "Message": "hiii", "Image": "5_201309091104109.jpg", "Likes": 7, "Status": 1, "OtherId": 3, "Friends": 0 } ], [ { "Id": 201309091100159, "PersonI ...

What is the best way to use appendChild within an AJAX get function to manipulate the DOM

I've been working on a code function where I try to append a list item (li) into the HTML received in 'msg', but it's not functioning properly. Any ideas why? function handleFileSelect(evt) { var files = evt.target.files; $(&ap ...

Finding a potential data breach in Node.js, MongoDB, and Chrome, exposed passwords are

My web app is built using nodejs with mongodb as the database backend, and I am encountering an issue with Chrome browser flagging my login process via passport.js as an exposed password. How can I prevent this warning? Should I implement something like Bc ...

Check the value of a single bit in JavaScript: Is the bit on (1) or off (0)?

Is there a way in JavaScript to determine if a single Bit is On (1) or Off (0)? function isBitOn(number, index) { // ... ? } // Example: let num = 13; // 1101 isBitOn(num, 0); // true 1 isBitOn(num, 1); // false 0 isBitOn(num, 2); // true 1 isBit ...

Show or hide the right element when clicked using ng-show in AngularJS

My goal is to toggle elements based on which one is clicked, not all at once. For instance, if I have 3 form elements and 3 buttons, when I click on button 1, I only want to toggle the corresponding form element. Here is my current code snippet: In Angu ...

Launch an Android application directly from a web browser upon the webpage's loading

When a user visits www.example.com/myApp, I want my app to open automatically without any click required. I have attempted the following methods: window.onload = function () { window.location.replace("intent://something#Intent;scheme=myapp;packag ...

I did not anticipate the React setState function to behave in the manner it did

While working on form validation for my page, I came across a tutorial showcasing a validation method that seems to be functioning correctly. However, there is one aspect that I am struggling to grasp. The tutorial suggests declaring a variable before the ...

What's the best way to decrypt a string in NodeJS?

In the midst of my NodeJS & MongoDB project, I've encountered a requirement to encrypt the content of articles before they are published. The catch is that the encrypted content should only be displayed if the correct key-codes are entered. For ...

Dealing with illegal characters, such as the notorious £ symbol, in JSON data within a JQuery

I'm encountering an issue with a textarea and the handling of special symbols. Specifically, when I use $('#mytextarea').val() to retrieve text that contains '£', I end up seeing the black diamond with a question mark inside it. T ...

Utilizing C# getter property for iterative deserialization

internal class Program { private static void Main(string[] args) { var sourceJson2 = "{\"bizType\":\"123\",\"data\":\"JzLw2uiQT4IzERg7hdGWFaPAilWJy7e4462Gd9VQ0Mbj0qZI3uDe6wWaSklECHjalCTEt/L1ZAyhf/fxocABc8 ...

"Utilize Cypress to simulate clicking a button by triggering the enter key

Currently, I'm conducting testing on my application and attempting to trigger a button click using the Enter key: <v-btn class="submit-button" block color="primary" @click="login" > Log In < ...

Measuring Time Passed with JavaScript

I've been working on a small piece of code that needs to achieve three tasks: User should input their birthday User must be able to view the current date When the user clicks a button, they should see the time elapsed between their birthday and the ...

"Function.click operates successfully when no arguments are given, but encounters issues when arguments are supplied

I had a function that was functioning correctly: $('#buttFurniture').click(onFilterCLick); However, when I decided to pass arguments to the function, it stopped working: $('#buttFurniture').click(onFilterCLick(arrOutput, arrFurniture ...

Storing user data on the client side of a website is most effectively accomplished by

I am looking to incorporate the following features: I would like to personalize the user experience by greeting them with their login name on the webpage (e.g. 'Hello, Fred!'). I also want to display or hide certain content based on the user&apo ...

Encountering difficulties during the installation of SonataUserBundle on Symfony2 version 2.4

I encountered an issue while trying to install sonata-project/user-bundle with Symfony2 2.4 using Composer. The error message that Composer gives me is as follows: Problem 1 - Conclusion: remove symfony/symfony v2.4.0 - Installation request for ...

What could be causing the Material-UI Appbar onLeftIconButtonTouchTap function to malfunction?

I am currently learning React-Redux and Material-UI. I'm working on creating a Sample App, but I'm facing some difficulties. I need help in improving my code. Specifically, I am trying to make the Drawer open when the Material-UI AppBar's on ...

Setting field names and values dynamically in MongoDB can be achieved by using variables to dynamically build the update query

I am working on a website where users can place ads, but since the ads can vary greatly in content, I need to be able to set the field name and field value based on user input. To achieve this, I am considering creating an array inside each document to sto ...

JavaScript Function to Redirect Page After a Delay of X Seconds

I'm trying to implement a redirect to a specific URL after displaying an error message for 5 seconds. Initially, I used JavaScript like this: document.ready(window.setTimeout(location.href = "https://www.google.co.in",5000)); However, the redirectio ...

The concatenation of Ajax results appears to append to the existing data

My ajax function handles uploading comments to a form, which then returns the same string. If successful, the comment is added to a comment box and the input text is cleared. The issue arises when a user adds another comment; the new comment is appended w ...