Trouble with getTime() function functionality in Chrome browser

My JavaScript code is functioning properly in IE and Firefox. Take a look:

var dt = new Date("17/05/2012 05:22:02").getTime();

However, when I try to run it in Chrome, the value of dt turns out to be NaN. I've been troubleshooting but can't seem to figure out what's causing this issue.

Answer №1

It appears that there is a recognized problem with the dd/mm format in Safari and Chrome browsers. More information can be found at this link.

Answer №2

Give this a shot:

let timestamp = new Date("05/17/2012 05:22:02").getTime()

Consider using Unix timestamps for dates since different browsers may handle them differently, or check out the library as an alternative option.

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

Executing a function in JavaScript from an AngularJS Controller

Currently, I am in the process of transitioning my jQuery calls to AngularJS. Previously, I created a web page for zip code lookup using the ziplookup library, accessible through this link. To implement this, I had to include the following script: <sc ...

Issue with Prettier AutoFormatting in a project that combines TypeScript and JavaScript codebases

Recently, I've started incorporating TypeScript into an existing JavaScript project. The project is quite large, so I've decided to transition it to TypeScript gradually. Below is a snippet from my eslintrc.js file: module.exports = { parser: ...

"Here's a simple guide to generating a random number within a specified range

I have encountered a specific issue: Within an 8-column grid, I am attempting to randomly place an item with a random span width. While I have successfully managed to position the item and give it a random width, I am struggling with adjusting the width b ...

The operation of executing `mongodb - find()` does not exist as a function

I am having trouble printing all documents from the "members" collection. I attempted to use the find() function, but encountered an error stating that find() is not a function. Here is a snippet from member_model.js located in the models/admin folder: v ...

Can we use classlist for adding or removing in Angular 2?

One of the features in my project is a directive that allows drag and drop functionality for elements. While dragging an element, I am applying classes to both the dragged element and the ones it's being dragged over. This is how I currently handle it ...

Having trouble getting the express router to function properly in your Node.js TypeScript project?

One of the components in this application is registerClass, where all routes are added. The source code is in the dist directory since this node app is using TypeScript. However, when calling the http://localhost:9001/user endpoint, it seems that it is not ...

The exceljs function for downloading an Excel workbook is not activated by using the Post method

Presently, I am engaged in the development of a React and Node application. This app is designed to store data entries in a database, with the capability for users to download all stored data in an Excel workbook. To make this possible, I have integrated ...

Introduction to AJAX: Conditional Statements

Within the menu.html file, there are various menu items (a href links) called menu_1, menu_2, and so on. The map.js file is responsible for displaying map content by utilizing an API to showcase different layers and maps. Even though there are many maps t ...

Need to know how to invoke a function from an http callback function that resides in a separate file? Simply use the `app.get("/", callbackFun)` method

Directory Organization: testAPI contactDetail dispMobNo.js myModule.js index.js index.js const express = require("express"); const app = express(); const port = process.env.port || 3000; const getCustNo = require("./cont ...

Error: Uncaught TypeError when using a for loop in Vue and GraphQL

I encountered a TypeError while attempting to iterate through a GraphQL query in my Vue project. The script snippet in question is as follows: <script> import { useQuery } from "@vue/apollo-composable"; import gql from "graphql-tag&qu ...

I'm having trouble getting the second controller to function properly in my AngularJS application

I've been looking everywhere for a solution on how to implement two controllers, but I can't seem to get it working. Could there be something wrong with my HTML or could the issue lie in my script? Here is the JavaScript code: <script> v ...

Utilizing async/await as a module function: A comprehensive guide

Express Route: const express=require('express'); const router=express.Router(); const trackRepo=require('../model/track'); router.post('/live',function(req,res){ const time=1439832167; const list=trackRepo.getAlerts ...

Mediawiki functionality experiencing issues within iframe display

Currently, I am working with MediaWiki built in PHP. Due to certain reasons, I have to embed this application within an iframe. All functionalities are running smoothly except for the Edit link for pages. The issue arises when I try to access the second li ...

What is the best way to include a css file in a react component directly as raw text?

What am I attempting to achieve? I have a WYSIWYG editor that allows me to create small HTML pages, and then it sends a request to save the page in the backend. Now, I want to include CSS in the request to apply all styles from the parent page (the one co ...

HTML comment without the presence of javascript

Is it possible to use different expressions besides checking for the browser or version of IE in order to display/hide content? For example: <!--[if 1 == 0]--> This should be hidden <!--[endif]--> I am considering this option because I send o ...

What is a way to automatically run a function at specific intervals in PHP, similar to the setTimeout() function in JavaScript?

I have a JavaScript code snippet that looks like this: setTimeout('$.ajaxCall("notification.update", "", "GET");', 1000); Now, I want to execute the following PHP function every 1000 milliseconds, similar to the above JavaScript code: $notific ...

Using VueJs, create a dynamic css class name to be applied inline

Can VueJs handle a scenario like this? Html: <div class="someStaticClass {{someDynamicClass}}">...</div> JS: var app = new Vue({ data: { someDynamicClass: 'myClassName' }, mounted: function() { ...

Converting Three JS from 3D to 2D dimensions

I am looking to convert the world space coordinates of a sphere into screen space coordinates in order to determine the screen space boundaries, which I then plan to use for overlaying a div element. It would be great if this function could also provide t ...

Obtain the Base64 encoding from the URL of an image

I am attempting to convert an image into a base64 string by providing its URL. Here is the HTML code: <input type="text" value="" id="urlFileUpload"/> <input type="button" id="btn" value="GO" /> And here is the JavaScript code: $('#btn ...

ExpressJS Node - .get switch to .route utilizing connect-ensure-login middleware

Considering that I have initially written a route using app.route: app.route('/word/:id') .get(word.getWord) .put(word.updateWord) .delete(word.deleteWord); Now, my aim is to modify the route by adding some middleware. While I am aw ...