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
date is optional. When not specified, the current date and time of the QIE server is formatted.
Parameters¶
| Type | Name | Description | Default |
|---|---|---|---|
| String | format | the format to apply to the date string | |
| String or Date | date* | (optional) the date to format. This can be either a date string, a java.util.Date object or a native JavaScript date object. |
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
);