Make Easy

Make Easy

Share

Specializing in brand identity, web design, and digital art, we craft visually compelling stories that resonate with your audience.

23/08/2024

Santa Clarita

20/11/2014

down vote


Here's a reasonably terse way to do it using a Prototype:

Date.prototype.getFormattedTime = function () {
var hours = this.getHours() == 0 ? "12" : this.getHours() > 12 ? this.getHours() - 12 : this.getHours();
var minutes = (this.getMinutes() < 10 ? "0" : "") + this.getMinutes();
var ampm = this.getHours() < 12 ? "AM" : "PM";
var formattedTime = hours + ":" + minutes + " " + ampm;
return formattedTime;
}

Then all you have to do is convert your string value to a date and use the new method:

var stringValue = "February 04, 2011 19:00:00;
var dateValue = new Date(stringValue);
var formattedTime = dateValue.getFormattedTime();

Or in a single line:

var formattedTime = new Date("February 04, 2011 19:00:00").getFormattedTime();

23/10/2014

Deepawali ka yeh paawan tyohar, Aapke Jeevan mein laye khushiya aapar. Shri Laxmi ji viraje aapke dwaar, Yeh Subhkamnayen hamari karen sweekar!! Wishing u & ur family a very Happy Diwali !!

Want your business to be the top-listed Computer & Electronics Service in Noida?
Click here to claim your Sponsored Listing.

Telephone

Address


Noida
201301