Analyzing past UTC date times results in a peculiar shift in time zones

When I receive various times in UTC from a REST application, I encounter different results.

Examples include 2999-01-30T23:00:00.000Z and 1699-12-30T23:00:00.000Z.

To display these times on the front end, I use new Date(date) in JavaScript to convert them to Time.

The issue arises with the resulting format of the converted time.

new Date("2999-01-30T23:00:00.000Z")
shows as
Thu Jan 31 2999 00:00:00 GMT+0100
, which is expected behavior.

However,

new Date("1699-12-30T23:00:00.000Z")
displays as
Wed Dec 30 1699 23:57:44 GMT+0057
.

Why does this unexpected output occur? What causes this peculiar time shift?

I am curious about finding the root of the problem or if there is any solution available. Unfortunately, my search has been unsuccessful so far.

Answer №1

Traveling back to the year 1699 takes us to a time when timezones were completely different than what we know today. For instance, in Denmark, the switch to CET did not occur until 1894, resulting in:

new Date("1893-12-31T00:00:00.000Z");
// Sun Dec 31 1893 00:50:20 GMT+0050 (Central European Standard Time)
new Date("1894-01-01T00:00:00.000Z");
// Mon Jan 01 1894 01:00:00 GMT+0100 (Central European Standard 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

Transferring JSON information from JavaScript to PHP using Jquery AJAX

Struggling to send JSON data from JavaScript to a PHP script using the code below. While debugging, "isRunning" initially shows true, indicating that AJAX is not running. However, when it moves to the next part of the AJAX code, "isRunning" changes to fal ...

How can JavaScript be utilized for connecting to CSS files?

I'm unsure if this is feasible and after a brief search, I couldn't find any information. I am curious to know if it's possible to connect a CSS file using JavaScript? In essence, I would like to invoke a style sheet when I execute a specif ...

What methods should I use to host my web application using Node/Express?

I have a question that may seem basic to some, but I'm completely lost when it comes to Node/Express. I have only worked with Apache servers (usually WAMP/XAMP for testing), so I have no clue how to serve my web app. My folder structure looks like th ...

Is it considered good practice to make a POST request within a GET request?

Is it considered good practice to make a POST request while also making a GET request in my app? Or is this frowned upon? In my application, the functionality works like this: when the page loads, it needs to retrieve user data. If the user data is not fo ...

Is it possible to transfer the reactivity of a Vue ref to another ref while reassigning it?

Below is a simplified version of my Vue component: <template> <div @click="loadEvents">{{ loading }}</div> </template> <script setup> import { ref } from 'vue' let loading = ref(false) loadEvents() func ...

Incorporating an HTML Canvas element within a CSS grid design

I've been attempting to integrate an html canvas that I created into one of the css grid classes specified in my code. The code runs when the "Calculate" button is clicked. Upon clicking the button, the <div> section designated for the canvas r ...

Having trouble with blurriness in the SVG image loading on three.js

Currently, I am using loadTexture (THREE.ImageUtils.loadTexture('/images/areaYellow.svg')) to load SVG images. However, when I zoom in on the image, it becomes blurred. Is there a way to load the image without this blurriness? I am currently work ...

The invocation of $.ajax does not work as a function

I'm encountering an issue when running npm start and trying to access the browser, I keep getting this error message in the stack trace. Error: $.ajax is not functioning properly at findLocation (G:\CodeBase\ExpressApp\routes\ind ...

The Observable merge operation encountered an error: it cannot access the 'apply' property of an undefined value

I am currently working on setting up a sorted DataTable in an angular application, and while implementing it using this example, I encountered the following error: ERROR TypeError: Cannot read property 'apply' of undefined at TableDataSource ...

Exploring ways to use TypeScript to export a Mongoose model?

There's a module I need to export in order to avoid the error "OverwriteModelError: Cannot overwrite Task model once compiled". I've tried various solutions but none seem to work. The problem lies in the last line (export default models...) impo ...

Utilize the cube function in JavaScript to zoom in on the cube automatically when the page loads

I have the code below. When the page loads, I would like the cube to zoom out and stop. I am new to 3js and have no idea how to achieve this. I want the cube to start small and then grow into a larger cube before stopping. <script> //var re ...

Disable the default controls on the Open Layers Bing Map

I am currently working on an App that utilizes Geolocation with Open Layers to load a Bing Map Layer. My goal is to enable touch-based zooming and remove the default zoom buttons. Additionally, I would like to relocate the 'i' button to prevent a ...

express.js does not properly support the app.get functionality

app.get('/:id', function (req, res){ UserModel.find({ user: req.params.id}, function (err, user){ if (err) throw err; console.log(user + '\n\n'); res.render('profile.ejs', { ...

Encountering a problem when utilizing window.ethereum in Next Js paired with ether JS

Experiencing some difficulties while utilizing the window.ethereum in the latest version of NextJs. Everything was functioning smoothly with NextJs 12, but after upgrading to NextJs 13, this error started popping up. Are there any alternative solutions ava ...

Trouble arises when jquery's "position().top" clashes with the CSS3 property "transform: scale()"

Currently, I am working on adding a font resizer feature to my editing tool. To implement this, I made some changes to the text elements where their origin is now set to the bottom left corner. The normal version of the tool works perfectly fine, but when ...

Ensuring continuous user login during webpage refreshes with the help of React and local storage

Currently, I am working on implementing the use of local storage to ensure that upon refresh, the user remains logged in rather than being signed out each time. Successfully, I have been able to store data in local storage by utilizing the following code ( ...

Retrieving specific data from nested arrays in Vue.js

I am currently working on Vue.js template development and facing an issue with filtering nested data in a faq section. When I try to add a search bar, the nested data array returns all data without proper filtering. Dom <v-container> <v ...

Extract the Top X elements from a multidimensional array

Consider an Array that consists of nested arrays: [ ["2000-01-01", "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d1a9a8abe091b6bcb0b8bdffb2bebc">[email protected]</a>", 1, 9, 338], ["2000-01-01", "<a href="/ ...

What is the best method to smoothly navigate to a specific id on a webpage after conducting a search using

I want to implement a jQuery function that allows me to scroll down to an id containing search results. The script as a whole, minus the JS, is functioning properly. I just need assistance in creating a method to search for specific id values. Below is my ...

Enabling logging for the Mapnik SQL query while generating the map

Currently, I am utilizing the npm package known as Mapnik in conjunction with PostGIS. My goal is to include logging functionality that captures the SQL query executed by Mapnik, along with the value of the bbox parameter, when executing the render() funct ...