Is Moment.js displaying time incorrectly?

When using moment.tz to convert a specific date and time to UTC while considering the Europe/London timezone, there seems to be an issue. For example:
moment.tz('2017-03-26T01:00:00', 'Europe/London').utc().format('YYYY-MM-DD[T]HH:mm:00')

This code returns: "2017-03-26T01:00:00Z" as expected.

However, when changing the input time to 02:00:00 like this:
moment.tz('2017-03-26T02:00:00', 'Europe/London').utc().format('YYYY-MM-DD[T]HH:mm:00')

The output unexpectedly becomes: "2017-03-26T01:00:00" instead of "2017-03-26T02:00:00". This discrepancy is puzzling and warrants further investigation.

Alternatively, if the time input includes a 'Z' at the end like this:
moment.tz('2017-03-26T02:00:00Z', 'Europe/London').utc().format('YYYY-MM-DD[T]HH:mm:00')

The result correctly appears as "2017-03-26T02:00:00". The reason behind this inconsistency remains unclear, sparking questions about the internal logic of the conversion process.

Answer №1

London experienced the start of Daylight Saving Time on March 26, 2016. At 2:00, the time offset was UTC+01:00, meaning the local time differed from Coordinated Universal 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

Setting up RTL (Right to Left) functionality in Material UI version 5 - A Step-by-Step Guide

After updating my app to version 5 of Material-UI from version 4, I noticed that the RTL support is no longer functioning. I carefully followed the instructions in the documentation: https://mui.com/guides/right-to-left/ The current outcome is that the ...

Can you explain the concept of 'each' when using the looping method in jQuery?

I'm grappling with accessing data within a table row. The data could be within a <td> tag, as text in an input field, or as a checkbox in an input field, or even as a button. To illustrate, here's a snippet of a small table: <table bor ...

Transform the string with binary hexadecimal characters in ASCII into a Buffer

Currently, I am utilizing node.js for my project. Within my code, there is a string variable called msg_str that contains the value "0102ab00aabb00". My goal is to convert this ASCII binary hex representation into a Buffer and have it displayed as <01 ...

Designating a class for the main block

Having an issue with a slider in uikit. When the slide changes, the visible elements also change their class to uk-active. I'm trying to select the central element from the active ones but css nth-child doesn't work. Any suggestions on how to do ...

I have developed a function that adds up price values, but for some reason it is always lagging one step behind

I am facing an issue with my React container that has add and subtract functions. These functions are triggered whenever a user clicks on '+' or '-' spans, to calculate the total 'price' of three different 'products' ...

Having trouble with Raphael's animation callback function?

It seems like I may not be using the callback feature correctly because when I run the code below, the "testCircle" doesn't animate before it disappears. var paper = Raphael(0, 0, 1280,600); var testCircle = paper.circle(300, 300, 50); test ...

Issue with Quantity Box not displaying values in Shopify store

I am currently seeking assistance with resolving an issue I have encountered on a Shopify theme that I recently customized. The problem lies within the quantity box on the live site where despite being able to adjust the quantity using the buttons, the act ...

No value found for Req.file using the express-fileupload and multer libraries

I have exhausted all possible scenarios and attempted various variations and methods recommended in the documentation and from other sources like Stack Overflow. However, none of them seem to work -> I constantly receive req.file is: undefined Here is ...

Refreshing the page causes JavaScript to fail loading

Recently, I encountered a puzzling error. Upon visiting this link The carousel fails to load properly near the bottom of the page. However, if you click on the logo or navigate back to the home page, it works fine. Additionally, performing a command + r ...

Tips for identifying the amount of <ul> elements contained within every div

Dealing with a large file structured in the same way, I am looking for a method to isolate a specific div, determine the number of ul's within it, and then iterate through each one to extract the value of every li element. <div class="experiment ...

Is it possible for Cypress to execute test files that are imported from outside of the Cypress folder

Currently, I am developing an E2E test framework using Cypress and encountered an issue while trying to import spec files from locations outside the traditional Cypress directory structure (which includes directories for fixtures, integration, plugins, and ...

Coding with a combination of JavaScript, AngularJS, and manipulating brackets

I am currently performing the following action: myArray.push(pageCount); After that, I end up with something like this: $scope.myArray = Pages.getAllPageCount(); Finally, when I utilize AngularJS to display it in my .html file. {{myArray}} If there i ...

Sorting and dividing an Array using Angular

Forgive me in advance if this sounds like a naive question, as Angular and Typescript are not my strong suits. I am assisting a friend with an issue that I can't seem to overcome. I have an array of players that includes details such as first name an ...

Display or conceal elements by utilizing ng-show/ng-hide according to specific conditions

Here is the code snippet I am working with: <input class="form-field form-control" type="text" name="Website" ng-model="vm.infodata.Website" placeholder="Website Address" maxlength="50" required ng-pattern="/^(www\.)?[a-zA-Z0-9_&bs ...

The Katura video is loading properly, yet it is rotating instead of playing

I am working on a web application that involves playing videos from Kaltura platform and then loading the link on an iOS webview. <html> <body> <div id="myEmbedTarget" style="width:400px;height:330px;"></div> ...

Positioning an Element on a Web Page in Real-Time

Trying to implement an Emoji picker in my React application, I have two toggle buttons on the page to show the picker. I want it to appear where the Toggle button is clicked - whether at the top or bottom of the page. The challenge is to ensure that the pi ...

Incorporate pug and sass into your React project for a more

Are pug/jade and sass compatible with react? I enjoy organizing my code by separating files, and the functionality that sass and pug provide is great for this purpose. Is there a way to integrate pug and sass into a react project? Pug example: doctype ...

Looping through ViewData strings and populating a form with their values

I am currently utilizing ASP.NET and MVC to work on a project where I need to take a list of strings and populate a form with them. The goal is for users to import account numbers, have the form prefilled with these numbers, and then submit the data. I&apo ...

Adjust the size of the font for the placeholder text

I've been attempting to adjust the font size of the placeholder text. I added the font size property to the listed classes below, but for some reason, it's not taking effect. Could you please advise me on how to resolve this issue so that I can ...

Is there a way to automatically hide divs with the style "visibility:hidden" if they are not visible within the viewport?

Currently, I am working on developing a mobile web app. Unfortunately, Safari in iOS 5.1 or earlier has limited memory capabilities. In order to reduce memory usage while using css3 transitions, I have discovered that utilizing the css styles "display:none ...