Change the RFC 1123 date format into a standard datetime format using JavaScript

Currently, I am utilizing the ASP.Net ajax calendar extender control in order to showcase both date and time.

<asp:TextBox ID="tbxReceivedDate" CssClass="selectstyle" runat="server" MaxLength="100" Width="200" onblur="parseStringtoDateTime();"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender1" TargetControlID="tbxReceivedDate" Format="ddd MM/dd/yyyy hh:mm:ss tt" runat="server"></cc1:CalendarExtender>

As of now, this textbox displays datetime as "Tue 08/18/2015 4:44:40 PM", but my goal is to convert it to "08/18/2015 4:44:40 PM" using JavaScript.

The code provided below only captures the date part, however, I also require the time section.

<script type="text/javascript">
    function parseStringtoDateTime() {
        var date = $find("behaviorID").get_selectedDate();
    }
</script>

Could you guide me on achieving this desired outcome?

Answer №1

Seems like your objective is to eliminate the initial 4 characters.

If we consider a scenario with a variable str="Tue 08/18/2015 4:44:40 PM", you can achieve this by using var mydate = date.substring(3);

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

Collapsible feature in Bootstrap malfunctioning after initial use

I am currently developing a website using PERSONA as the CMS and have implemented collapsible elements on the page using Bootstrap. The website is using Bootstrap Version 3.3.7 and PERSONA includes an internal version of jQuery. For reference, you can acce ...

Include web browsing history

In my ASP.Net/VB project, I am facing an issue with floating DIVs. Whenever users try to close the floating DIV by clicking on the back button in their browser, it creates a confusing experience. My solution is to add a "#" entry to the browser history wh ...

MVC: Issue with client-side validation ceases to function after the initial opening and closing of SimpleModal AJAX popup

I am currently facing an issue with a view that includes a simplemodal popup window. When you click on a hyperlink, the window pops up, and if you try to submit the form in the popup without filling in any information, it displays the appropriate validatio ...

What is the best way to initialize firebase with context in a React application?

Currently, I'm following a tutorial at this link: I've hit a roadblock at the following step: Context.jsx import React from 'react'; const FirebaseContext = React.createContext(null); export default FirebaseContext; index.js impo ...

Mongoose: fetching values exclusively

I am currently utilizing Mongoose to query my User schema, which contains: var usersSchema = new Schema( { email : String, regId : { type : String , default : '' }, lastName : { type : String , default : '' ...

Create a duplicate of a div using JavaScript and modify the IDs of the inner elements within

I have two static div tags with a select tag and a text box inside, each with different IDs. When I clone the tag, it duplicates the same div tag in the DOM. How can I change the inner elements' tags? Below is the code snippet: <div id="m ...

Find the width of the initial cell in the primary column within the GridView

Seeking assistance with an ASP.NET GridView - I am looking for a way to manipulate the width of the first cell in the initial column using jQuery. Your help is greatly appreciated! ...

Generating 100,000 rows in an XML file using XDocument is proving to be quite time-consuming

Struggling to add numerous rows of nodes within an existing xml file, specifically trying to insert an average of 100,000 rows. The process is functioning as intended, but it is incredibly slow. After waiting for 10 minutes without completion, I had to hal ...

Retrieving Data with an Ajax POST Request

I have implemented an Ajax setup to transfer data to a PHP script for the purpose of writing values to a database: $.ajax({ type: "POST", data: "action=vote_down&id="+$(this).attr("id"), url: "vote.php", success: function(msg) { ...

What is the purpose of using GC.SuppressFinalize() in the absence of a Finalizer implementation?

I'm curious about something - I've been asked a question and have no idea what the answer is! Is there any logical explanation for this at all? ...

Encountering problems due to the addition of an event listener on my webpage

Currently working on a nodejs app utilizing react and encountering an issue when running yarn start. The error message "TypeError: btn_bmi.addEventListener is not a function" keeps popping up. This setup has worked for me before but now I'm unsure abo ...

Is there a more efficient method for transforming an HTML form into an object through serialization?

I'm in the process of creating a form that includes both radio and checkbox inputs. Since multiple elements share the same name, I have developed the following solution. Is there a more efficient and simpler way, using only pure JavaScript, to conver ...

What is the best way to transfer the userId from the browser to protractor?

Using *ngFor in my angular2 component to render users has been successful. <ul> <li *ng-for="let user of users"> <input [(ng-model)]="user.name"> <button (click)="remove(user._id)">Remove</button> ...

Mastering the retrieval of array elements in React.js

I have been working on creating a calendar event with react and momentjs, and everything seems to be functioning well. However, I am now facing an issue where I need to access a specific element in the array that looks like this in the console. console ...

What could be the reason for the GET request not functioning properly in Node.js?

const express = require('express'); const mongoose = require ("mongoose"); const app = express(); const Student = require('../models/students'); require('dotenv').config(); const PORT = process.env.PORT || 3000; const co ...

Ways to divide an array into several smaller components

After reading an insightful article about array forms in React on https://goshakkk.name/array-form-inputs/, the idea struck me - could I break down Goshakk's component into smaller, more manageable components? My attempt to do so hit a roadblock when ...

What are the common reasons for ajax requests to fail?

Every time I try to run the code with the provided URL, the alert() function in the error: function is triggered. Can someone please assist me with this issue? $("#button").click(function(){ $("#form1").validationEngine(); if($('div input[typ ...

Tips for leveraging a JSON array for verifying passwords:

Looking for assistance with looping through a JSON array for password validation. Can anyone provide some guidance? const pwdarray = { "pwd":[ { "TEXT":"Password must be at least 6 character(s) long.", "EXPRESSION":"/(^(.){6, ...

Why is it that when I use require.js, all my modules appear to be loading at once when the page first

During the development of my single-page backbone app using requirejs, I encountered an issue when deploying to our beta server. The initial page load took around 20 seconds as it had to fetch all the necessary scripts. I initially believed that this dela ...

Implementing ReactJs content from one page to another using jQuery ajax

I have been developing an application and have created some views in React Js. I am now looking to load these views onto another page using jquery load. Is this possible? [Let's say leave.html contains the react code. Now, I want to load leave.html i ...