Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

245
Views
Chrome local storage is not storing dates correctly

When setting data in Chrome's local storage containing a date, all the data is correctly retrieved except the date that disappears, but I really don't know what I am doing wrong.

await browser.storage.local.remove("ghunt");
var payload = {"ghunt": {
                "cookies": "dummydata",
                "date": new Date(),
                "step": "login"
            }};
console.log("Raw payload => ", payload);
console.log("Putting the payload in local storage...")
await browser.storage.local.set(payload)
console.log("Retrieving data from local storage...")
var storage = await browser.storage.local.get("ghunt");
console.log("Retrieved data => ", storage);

The exact same code / commands works perfectly on Firefox.

PS : I am using WebExtension-Polyfill from Mozilla to provide cross-browser support

Firefox output screenshot
Chrome output screenshot

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

MDN on StorageArea.set() (emphasis mine):

It's generally not possible to store other types, such as Function, Date, RegExp, Set, Map, ArrayBuffer, and so on. Some of these unsupported types will restore as an empty object, and some cause set() to throw an error. The exact behavior here is browser-specific.

Store new Date().getTime(), which is an integer, not new Date().

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!