qie.formatDate¶
Signature: qie.formatDate(format, date*)
Returns: String formattedDate - the formatted date string
Applies the specified format to the date and returns the resulting string.
Note
Calling qie.formatDate(format) without specifying a date, returns the current system date/time in the specified format.
Parameters¶
| Type | Name | Description | Default |
|---|---|---|---|
| String | format | the format to apply to the date string | |
| String or Date | date* | (optional) the date that is to be formatted. This can be either a string representing a date or a java.util.Date object or a native javascript date object. | null |
Example¶
// Example: no date provided (uses current system date/time)
var today = qie.formatDate("yyyy-MM-dd");
// Example: date as String
var formattedFromString = qie.formatDate(
"MM-dd-yyyy",
"2018-05-08"
);
// Example: date as java.util.Date
var dateObj = qie.deduceDate("2018-05-08"); // Date Object
var formattedFromDate = qie.formatDate(
"MM-dd-yyyy",
dateObj
);
// Example: date as native JavaScript Date
var jsDate = new Date(2018, 4, 8); // Months are 0-based (4 = May)
var formattedFromJsDate = qie.formatDate(
"MM-dd-yyyy",
jsDate
);