question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JavaScript Date instances don't seem to represent localdate

See original GitHub issue

In browsers new Date("2021-12-18T22:23") seem to produce a local date time. So when calling new Date("2021-12-18T22:23").toISOString() on my local machine (situated in Timezone Europe/Berlin) the resulting string will be 2021-12-18T21:23:00.000Z The browser implementation seems to calculate the UTC time from the Date instance.

grafik

But when running this in HTMLUnit I wasn’t able to get the correct UTC string. Even when setting the Timezone on the browser version.

I changed my example project https://github.com/thuri/htmlunit-jquery-selector-init that was created for #422 and added a new Test DateStringConversionTest.java and an new example html dateStringConversionTest.html where this behavior can be reproduced.

Probably i’m just missing some configuration here but I couldn’t find something on the web

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
rbricommented, Dec 22, 2021
0reactions
rbricommented, Feb 9, 2022

This is fixed with the 2.58.0 release. Thanks for this report.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is the Javascript date object always one day off?
Javascript's Date class doesn't represent a date, it represents a timestamp (same in Java). To make it a date, it uses a time...
Read more >
Demystifying DateTime Manipulation in JavaScript - Toptal
Time and date manipulation is notoriously difficult. Developers encountering time zone rules, leap seconds, differences in locale-specific formatting are ...
Read more >
A Complete Guide to JavaScript Dates (and why your date is ...
The primitive value of a JavaScript Date is straightforward. As we discussed, it represents the number of milliseconds since midnight on Jan 1st ......
Read more >
Understanding Date and Time in JavaScript | DigitalOcean
JavaScript comes with the built in Date object and related methods. This tutorial will go over how to format and use date and...
Read more >
Everything You Need to Know About Date in JavaScript
If you want to create a date in Local Time with the date-string method, you need to include the time. When you include...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found