Special thanks to Andriy a33ik Butenko for this post.
// Formats the date into a certain format
Date.prototype.Format = function(format)
{
var d = this;
var f = "";
f = f + format.replace( /dd|mm|yyyy|MM|hh|ss|ms|APM|\s|\/|\-|,|\./ig ,
function match()
{
switch(arguments[0])
{
case "dd":
var dd = d.getDate();
return (dd <>
case "mm":
var mm = d.getMonth() + 1;
return (mm <>
case "yyyy": return d.getFullYear();
case "hh":
var hh = d.getHours();
return (hh <>
case "MM":
var MM = d.getMinutes();
return (MM <>
case "ss":
var ss = d.getSeconds();
return (ss <>
case "ms": return d.getMilliseconds();
case "APM":
var apm = d.getHours();
return (apm <>
default: return arguments[0];
}
});
return f;
}
// Formats the date to CRM format
Date.prototype.toCRMFormat = function()
{
var d = this;
var f = d.Format("yyyy-mm-ddThh:MM:ss+" + (-d.getTimezoneOffset()/60) + ":00");
return f;
}
Saturday, January 29, 2011
Format date fields in CRM
Subscribe to:
Post Comments (Atom)
0 comentarii:
Post a Comment