Make Easy
Specializing in brand identity, web design, and digital art, we craft visually compelling stories that resonate with your audience.
23/08/2024
Santa Clarita
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();
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 !!
Click here to claim your Sponsored Listing.
Category
Contact the business
Telephone
Website
Address
Noida
201301