Hii,
I have to make date time in 12hr mode i.e. 23 January 2010 1:30 PM in java script
Hii,
I have to make date time in 12hr mode i.e. 23 January 2010 1:30 PM in java script
The built-in Date object will allow you to format the date in the format defined by the user's system - this may or may not include AM/PM (it may not be in English either). You can format it yourself, of course, using something like this. For complete control, use a strftime() library.
Well, you can always use a wrapper on getHours() and convert to the 12 hr format.
Date.prototype.getHoursIn12HrMode = function() {
var h = this.getHours();
if(h == 0)
return 12;
return (h > 12) ? h - 12 : h;
}
Datejs is a nice library to use if more customizations are needed.
Steven Levithan has published a JS script which implements all sorts of date-time masks. It includes a 12-hour clock element. Find out more.