JavaScript date parsing problem

When I fetch values from a datatable that has a column of type DateTime, I then serialize it using the Json.Net library.

jsonData = JsonConvert.SerializeObject(datatable);

The original date in the datatable was: 2013-04-03 04:01:24.623. After serialization, it is stored in jsonData as: 2013-04-03T04:01:24.623.

On my webpage, I am displaying it as:

timeStamp = new Date(jsonRow.TimeStamp).toLocaleString(); // Here jsonRow.TimeStamp is extracted from the JSON response received.

However, when viewed in Safari browser, it shows an error: Invalid Date.

Answer №1

If you're facing a similar issue, check out this question on Stack Overflow about the discrepancies in date parsing between Safari and Chrome: Date parsing in JavaScript is different between Safari and Chrome

Hopefully, this solution will be helpful to you :)

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

Is there a way to stop TinyMCE from adding CDATA to <script> elements and from commenting out <style> elements?

Setting aside the concerns surrounding allowing <script> content within a Web editor, I am fully aware of them. What I am interested in is permitting <style> and <script> elements within the text content. However, every time I attempt to ...

Golang decodes JSON using static typing rather than dynamic typing

I used to believe that json.Marshal utilized reflection to examine the passed type and then decoded it accordingly. However, I encountered an issue when I had a variable with a static type of any which actually stored a struct, and when passed to json.Unma ...

Using JSON to create a line chart with multiple lines in Apexchart

After following the Apexchart Json function, I found it to work smoothly for a single line of data in a barchart. I have experimented with creating different examples from their site, and they were straightforward to understand and all successful. Now, m ...

Every time an endpoint is triggered, it seems like a new global object for the self-hosted WCF service is being created

After following the steps outlined in this tutorial, I have successfully self-hosted a WCF service within a Windows service. Within my WCF service, there is a global object that I update regularly. My goal is to serialize this object into JSON and return t ...

Struggling with jquery .append issue

Here is the HTML code snippet: <div class="expand"> <div class="title" id="SectionTitle2">Academics</div> <input type="button" onclick="showTitleForm('2');" name="editTitle2" value="Edit Title"> <form id="titleForm2" m ...

Adjusting the size of a Video/Image Slider to perfectly fit the screen dimensions (both width and height

I have been using a slider code to display my images and videos. The code can be found here: Code:https://codepen.io/1wdtv/pen/jbjZeb The issue I am facing is that the slider is only responsive in terms of width. This means that when resizing the browser ...

Find and conceal the object within the list that includes the term "Ice"

The teacher's assignment is to create a radio button filter that hides items with the word "Ice" in them, such as "Ice Cream" and "Iced Tea." Here is the current code I have been working on: <!DOCTYPE html> <html> <head> <me ...

Using node.js with express to send data stored in a variable to the browser instead of displaying it in the

I'm currently getting the hang of node.js. It's pretty straightforward to use res.send and output some basic "hello world" text, but how can I pass variables to the browser instead of just to the console? Here is a snippet of code: var Tester = ...

Performing array reduction and summation on objects in JavaScript

Data Analysis: dataSet: [], models: [ { id: 1, name: "samsung", seller_id: 1, count: 56 }, { id: 1, name: "samsung", seller_id: 2, count: 68 }, { id: 2, name: "nokia", seller_id: 2, count: 45 }, { id: 2, name: "nokia", seller_id: 3, count: ...

Undefined data is frequently encountered when working with Node.js, Express, and Mongoose

Having a beginner's issue: I'm attempting to use the "cover" property to delete a file associated with that collection, but the problem is that it keeps showing up as "undefined". Has anyone else encountered this problem before? Thank you in adv ...

Using a React component to import a module for publishing on NPM

Creating my first React component for NPM publication has been quite the learning experience. I decided to use the react-webpack-component package from Yeoman to kickstart my project. However, upon installing and importing my component into a React app, I ...

Ensure the accuracy of submitted form information

I am seeking to enhance the validation process for my form, which is already using jquery.validate.min.js for validation. I want to incorporate another layer of validation by making an ajax call to my MySQL database to check if the email address provided i ...

What reasons could be preventing the state from updating correctly in Vuex?

Currently, I am working on a project where I am utilizing vuex along with axios to retrieve data from the backend. The issue arises when I try to access the state - even though the updated state is displayed successfully when I console-log it, there seems ...

Tips for styling a React JS component class

I am attempting to write inline CSS for a React JS component called Login, but I keep encountering an error. What could be causing this issue? Could you provide guidance on the correct way to implement in-line component CSS? import React, {Component} from ...

What is the best way to incorporate JQuery into html content retrieved through an ajax request?

In my jsp file, there is a div structured like this : <div id="response" class="response"></div> After triggering an ajax call to a servlet, the content of this div gets updated with the following elements : <div id="response" class="res ...

Storing extensive JSON data with AJAX, jQuery, and Java

Currently, I am utilizing jQuery AJAX to call a server-side method and sending a JSON string to the controller. Everything works smoothly when the JSON size is small, but as soon as it exceeds 7kb, the server side rejects the JSON string. I suspect that t ...

Determine if the elements in an array are identical using the reduce() method

I'm looking to compare all values within a single array to determine if they are all equal or not. My current method is working correctly and providing the expected result. var myArray1 = [50, 50, 50, 50, 50]; // all values are the same, should re ...

Is it necessary to ensure application readiness before proceeding with unit testing exports?

I've been facing a challenge while trying to utilize Jest for unit testing an express API that I've developed. The issue arises when the database needs to be ready before running the test, which doesn't seem to happen seamlessly. In my serve ...

Error encountered: "unable to resolve jsonObject in Json array parsing"

I am facing a challenge with parsing the array (cars) from the following JSON data: [ { "name": "John", "city": "Berlin", "cars": [ "audi", "bmw" ], Even though I attempted to parse it with the code below, I encountered an error: JSONParser parser = new ...

Selecting a full table row activates a top-up popup

I have successfully implemented a script in Javascript to enable full table row selection as shown below. <script type="text/javascript"> $(function() { $('#link-table td:first-child').hide(); $('#link-table tr').hover(func ...