-
Notifications
You must be signed in to change notification settings - Fork 26
MobileCRM.CultureInfo.formatDate
rescocrm edited this page May 15, 2023
·
9 revisions
[v10.2] Returns the formatted date/time string that matches current device culture.
This method fails if CultureInfo.initialize method hasn't completed yet.
Argument | Type | Description |
---|---|---|
date | Date | A date being formatted. |
format | String | Custom format string that meets the MSDN Sepcification. |
This example demonstrates how to format current date to a string having pre-defined or custom format.
MobileCRM.CultureInfo.initialize(function (currentCulture) {
///<param name='currentCulture' type='MobileCRM.CultureInfo' />
var formatDate = new Date();
var monthDayPattern = "MM-MMMM, ddd-dddd";
var customDate = MobileCRM.CultureInfo.formatDate(formatDate, monthDayPattern);
var fullDateTime = MobileCRM.CultureInfo.fullDateTimeString(formatDate);
var longDate = MobileCRM.CultureInfo.longDateString(formatDate);
var longTime = MobileCRM.CultureInfo.longTimeString(formatDate);
var shortDate = MobileCRM.CultureInfo.shortDateString(formatDate);
var shortTime = MobileCRM.CultureInfo.shortTimeString(formatDate);
var mothDay = MobileCRM.CultureInfo.monthDayString(formatDate);
var yearMonth = MobileCRM.CultureInfo.yearMonthString(formatDate);
var result = monthDayPattern + ": " + customDate + "\n" +
"full date time : " + fullDateTime + "\n" +
"long date : " + longDate + "\n" +
"short date : " + shortDate + "\n" +
"long time : " + longTime + "\n" +
"short time : " + shortTime + "\n" +
"day of month : " + mothDay + "\n" +
"year of month : " + yearMonth + "\n";
MobileCRM.bridge.alert(result);
}, MobileCRM.bridge.alert, null);