diff --git a/core/src/main/java/lucee/runtime/functions/displayFormatting/DateTimeFormat.java b/core/src/main/java/lucee/runtime/functions/displayFormatting/DateTimeFormat.java index 0b854f6dc4..ddf93519f7 100644 --- a/core/src/main/java/lucee/runtime/functions/displayFormatting/DateTimeFormat.java +++ b/core/src/main/java/lucee/runtime/functions/displayFormatting/DateTimeFormat.java @@ -92,6 +92,16 @@ public static String invoke(DateTime datetime, String mask, Locale locale, TimeZ else if ("long".equalsIgnoreCase(mask)) format = java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.LONG, java.text.DateFormat.LONG, locale); else if ("full".equalsIgnoreCase(mask)) format = java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.FULL, java.text.DateFormat.FULL, locale); else if ("iso8601".equalsIgnoreCase(mask) || "iso".equalsIgnoreCase(mask)) format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX"); + else if ("epoch".equalsIgnoreCase(mask)) { + String gettime = String.valueOf(datetime.getTime() / 1000); + String epoch = gettime.toString(); + return epoch; + } + else if ("epochms".equalsIgnoreCase(mask)) { + String gettime = String.valueOf(datetime.getTime()); + String epoch = gettime.toString(); + return epoch; + } else { SimpleDateFormat sdf; format = sdf = new SimpleDateFormat(convertMask(mask), locale); diff --git a/core/src/main/java/resource/fld/core-cfml.fld b/core/src/main/java/resource/fld/core-cfml.fld index 935489bbad..e0257a3faf 100755 --- a/core/src/main/java/resource/fld/core-cfml.fld +++ b/core/src/main/java/resource/fld/core-cfml.fld @@ -451,6 +451,8 @@ The following masks can be used to format the full date and time and may not be - long: medium followed by three-letter time zone; i.e. "mmmm d, yyyy h:nn:ss tt zzz" - full: equivalent to "dddd, mmmm d, yyyy h:nn:ss tt zz" - ISO8601/ISO: equivalent to "yyyy-mm-dd'T'HH:nn:ssXXX" +- epoch: Total seconds of a given date (Example:1567517664) +- epochms: Total millseconds of a given date (Example:1567517664000) The function follows Java date time mask. For details, see the section Date and Time Patterns at http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html