Back to Top

Convert 12-hour datetime to 24-hour datetime in JavaScript

Convert 12-hour datetime to 24-hour datetime in JavaScript

Here I am going to share one function I have used to change the date from 12 hours to 24 hours.Recently I want to store date into the database and to store date into the database, you need to have a particular format, you can’t save as 12 hours AM or PM.

So, I have displayed a date as 12 hours with AM or PM and then apply following function which convert 12 hours date into 24 hours.

Let’s understand the code:

That’s it. You can alert your date and check you get the right format of the date.

Also Read:

JavaScript Ticker for Database Values
To convert PHP array into Javascript array
Convert date from one format to another format using javascript

As always, thanks for reading. Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.

Leave a Reply

Your email address will not be published. Required fields are marked *

Most Popular Posts

How to use jQuery Cookie

Posted on 5 years ago

Bhumi

MySQL coalesce() function

Posted on 6 years ago

Bhumi

JQuery Animation effects

Posted on 5 years ago

Bhumi

How to save image in MySQL Database

Posted on 6 years ago

Bhumi

Overview of ECMAScript 6 new Features

Updated 18 years ago

Bhumi

Getting started with Amazon Web Services

Updated 18 years ago

Bhumi

Facade implementation in Laravel

Updated 18 years ago

Bhumi

The Reader’s Poll – June 2015

Posted on 2 years ago

Bhumi

The Reader’s Poll – August 2014

Posted on 3 years ago

Bhumi

The Reader’s Poll – June 2014

Posted on 3 years ago

Bhumi

The Readers’ Poll – May 2014

Posted on 3 years ago

Bhumi

The Readers’ Poll – August 2013

Posted on 4 years ago

Bhumi