Please rate how useful you found this document: 
Average: 3.2 (6 votes)

Date Functions

formatDate()

formatDate() formats a date string according to a given date format and given language. Note that ProcessMaker stores the input in date fields in Dynaforms as strings.

string formatDate(string date, string format, string language='en')

Parameters:

  • string date: The input date to be reformatted. The input date must be a string in the format 'yyyy-mm-dd' or 'yyyy-mm-dd h:i:s', such as '2015-12-31' or '1998-02-07 22:50:08'. This is the same format used to store dates and datetimes by the MySQL database and datetime fields in Dynaforms.
  • string format: The format of the date that will be returned. It can contain the following codes:
    • yyyy - shows the year with four numbers (e.g. it shows the year 2008 as 2008)
    • yy - shows the year with two numbers (e.g. it shows the year 2008 as 08)
    • mm - shows the month with two numbers (e.g. it shows June as 06)
    • m - shows the month with a simple number (e.g. it shows June as 6)
    • M - shows the word for the month in the selected language (e.g. if the month is June, it shows June in English and junio in Spanish)
    • dd - shows the day of the month with two numbers (e.g. the first day of the month is 01)
    • d - shows the day of the month with a simple number (e.g. the first day of the month is 1)
    • h - shows the hour with two numbers in a 24 hour clock (e.g. 2pm is 14)
    • i - shows the minutes with two numbers (e.g. first minute is 01)
    • s - shows the seconds with two numbers (e.g. first second is 01)
  • string language: The language used to reformat the date. It can be 'en' (English), 'es' (Spanish) or 'fa' (Persian). If not included, English is set as the default language.

Return value:

  • string: Returns the date passed in the given date format.

Note: For other languages, use PHP's strftime() function. See Formatting Dates in Other Locales.

Examples:

The value of @@textBox will be 'June 11, 2008':

@@textBox = formatDate('2008-06-11', 'M dd,yyyy', 'en');

The value of @@textBox will be '7 de Junio del 2008':

@@textBox = formatDate('2008-06-07', 'd de M del 2008', 'es');

The value of @@textBox will be '07/06/08 06:45:04':

@@textBox = formatDate('2008-06-07 06:45:04', 'dd/mm/yy h:i:s');

(In this example, the language parameter is omitted and English is used by default)

getCurrentDate()

getCurrentDate() retrieves the current date in the format "yyyy-mm-dd", with leading zeros in the month and day if less than 10. This function is equivalent to PHP's date("Y-m-d").

string getCurrentDate()

Parameters:

  • This function does not need any parameter.

Return value:

  • string: Returns the current date as a string value.

Example:

If the current date is December 16, 2009:

@@myTextBox = getCurrentDate();

The value of @@mytextBox will be '2009-12-16'.

getCurrentTime()

getCurrentTime() returns a string with the current time in the format "hh:mm:ss" with leading zeros when the hours, minutes or seconds are less than 10. The hour is expressed in the 24 hour format (military time) and is a number between 00 and 23. This function is equivalent to PHP's date('H:i:s').

string getCurrentTime(void)

Parameters:

  • This function does not need any parameters.

Return value:

  • string: The function returns the current time as a string.

Example:

If the current time is 9:13 am, then:

@@curTime = getCurrentTime();

The value of the @@curTime will be '09:13:23'.

literalDate()

literalDate() returns a specified date written out in a given language, (e.g, English: "2008-06-11" returns "June 11, 2008", Spanish: "2008-06-11" returns "11 de Junio de 2008").

string literalDate(string date, string language='en')

Parameters:

  • string date: The input date as a a string in standard YYYY-MM-DD format.
  • string language: The displayed language, which can be 'en' (English) or 'es' (Spanish). If not included, then it will be English by default.

Return value:

The literal date is returned as a string.

Note: For other languages, use PHP's strftime() function. See Formatting Dates in Other Locales.

Example:

@@textBox = literalDate("2009-12-17", "en");

The returned value stored in @@textBox will be 'December 17, 2009'.