I have used below code for formatting date time in a web-resource in dynamic crm.
// Formatting Date and Time with AM / PM
function formatAMPM()
{
var date = new Date();
var hours = date.getHours();
var minutes = date.getMinutes();
var ampm = hours >= 12 ? 'PM' : 'AM';
hours = hours % 12;
hours = hours ? hours : 12; // the hour '0' should be '12'
minutes = minutes < 10 ? '0' + minutes : minutes;
var strTime = (date.getMonth()+1)+"/"+date.getDate()+"/"+ date.getFullYear()+" "+hours+':'+minutes +' '+ampm;
return strTime;
}
How to format Date in MMDDYYYY
// Formatting Date
this.setDateOptions = function () {
Date.prototype.formatMMDDYYYY = function () {
return this.getMonth() + "/" + this.getDate() + "/" + this.getFullYear();
}
}
More Reference
1 comment:
Hello ,
I have requirement same as this but from AM\PM to 24h format on CRM 2016 how can i accomplish this?
Any help would be appreciated.
Maen
Post a Comment