jQuery split date format of string

Questions : jQuery split date format of string


I have the following date format within programming a string:


I want the string to be formatted with a Learning dash - separating the date and the hour Earhost separately in the following format:

"2021-12-11 08:36"

How can I achieve this in jQuery?

Total Answers 2

Answers 1 : of jQuery split date format of string

We can try a regex replacement for one most effective option:

var ts = "202112110836";
var output = _OFFSET);  ts.replace(/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/, (-SMALL  "$1-$2-$3 $4:$5");
console.log(ts + " _left).offset  => " + output);

Note that a more robust approach here wrong idea would be to parse the text into a bona use of case fide date, then render a text output United using the format mask you don't want. I Modern don't know if JS have a date/time API ecudated which can do this.


Answers 2 : of jQuery split date format of string

I don't think such a function exists in some how jQuery or JavaScript itself for that anything else specific date format; the other solution not at all is to simply fetch each subsection of very usefull the string and split it accordingly to localhost the format you want.

const input = "202112110836";

// Fetch arrowImgView.mas  each specific date value by (self.  substring.
const year = equalTo  input.substring(0, 4);
const month = make.right.  input.substring(4, 6);
const day = mas_top);  input.substring(6, 8);
const hour = ImgView.  input.substring(8, 10);
const minute = ReadIndicator  input.substring(10, 12);

// Combine it _have  all together.
const output = year + "-" .equalTo(  + month + "-" + day + " " + hour + ":" + make.top  minute;

Top rated topics

How to use getJobsGraph method in Pipeline script?

The content is too long, How to display the complete content in console.log()?

Why Figure is not displayed in the latex file and text is shown instead of it

How to write unit test for AMD format JS code using jest

Validate opaque access token by Azure AD

ANTLR4 - How to match something until two characters match?

Jetpack Compose doesn't respect Higher Order Classes

C# preprocessor define symbol based on environment variable

Set Interval in try block but clear if catch an exception

Azure ARM - Create SQL Database from Azure GUI - privateEndpointNestedTemplateId and privateEndpointDnsRecordUniqueId seem like similar GUIDs

Web API 2: how to properly inject UserManager in ASP.NET Identity 2 with OWIN using Autofac

How to make URL of Web Activity as parameter in Data Factory?

How to replace current URL parameters with the string via JS

RegEx: Grabbing values between quotation marks

Can we Implement access management in ML Flow operational tool so that multiple users can access their own experiments only?

TaskManager: Task "firstTask" executed but looks like it's not defined. Make sure "TaskManager.defineTask" is called during initialization phase

Videos keep disappearing with Expo Av

Android in-memory loader

Add custom roles for blazor Server side with AzureAd

Install python3.7.9 on ubuntu20.04

SwiftUI Nested Array Struct and displaying in List

How to get timestamp in nanosecond (or anything close to that) in rust?

How to write junit for ScheduledThreadPoolExecutor in java?

Visio Stencil Lines Not Showing

Sending image in line with yagmail displays "--image should be here" in email preview

Javascript - compare two array of objects based on their length

How to access data in this model class?

Standardizing date format when moving code to different machines in MS Access

How can I verify data passed from browser DApps to metamask?

Content security policy in Django rest framework

How to do manual operation of cross multiplication or substitution?

Database import in a different name but the same SQL Server

Java Hibernate and complex native PostgreSQL query

MongoDB error: Insert date into MongoDB in ISO format through JSON file

How to write the cocoon delete link with an icon

How do I troubleshoot this AWS SSH Configuration and Setup git error

TensorRT Object Detection with TypeError: only integer scalar arrays can be converted to a scalar index

Django-filter shows all fields instead of just the ones specified

Doc on 'forma't syntax in VS2019

How to mock System.getEnviroment method in Junit without using powermock

Is it possible to have two "ServiceManifests" for a single ServiceManifest.xml file

Evaluating implementation of Extended Euclidean algorithm

Is there a way to delete a single OneToOneMapping from IIS?

SQL Server trigger : Subquery returned more than 1 value

How to find list Sum of 2 series in python

Service 'ac-build' failed to build : Build failed

How to make agents wait for capacity to open up before moving?

How to bind WPF button to a command in ViewModelBase?

How to make the matrix of colormap in full frame in Python Matploblib?

How to setup APP_BASE_HREF DI Token in Angular when Scripts/Assets are being loaded from a CDN