Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Capturing dates and time accurately is important because because frevvo forms and workflows are designed to be used anywhere in the world, streamlining our customer's business processes. This chapter will consolidate information from several other documentation chapters related to working with dates and times in in frevvo.

Insert excerpt
Palette Controls
Palette Controls

...

The Date Format property applies to Date controls and the Date portion of the Date/Time control. The default, recommended format is "Automatic", which is a locale-specific date format. The designer has the option to set a particular date format independent of the locale by using the format field, but this is not recommended. Read this documentation for more information about date controls and internationalization.  

Available Date Formats consist of three different separators (dash '-', slash '/', or period '.') and four date display formats (DD/MM/YYYY, MM/DD/YYYY, YYYY/MM/DD, or Mmm/DD/YYYY). European date formatting is supported. 

...

  1. A date typed into a form field will be reformatted to match the selected Date Format 
  2. A date entered into a form field will be translated according to the selected format. For example, if you choose a European format of DD-MM-YYYY and the user enters 10-05-2009, the date value will be translated as May 10, 2009. If you choose a US format of MM-DD-YYY the date value will be translated as October 5, 2009. 
  3. Any of the three separators will be valid for date entry but will be translated to the selected separator. For example, if you choose a format of MM/DD/YYY and the user enters 10-05-2009, the date will display 10/05/2009.
  4. Dates entered like Feb 3, 2001 will be translated into the specified format.

 adjusts frevvo adjusts dates expressed with a two-digit year to be within 80 years before or 20 years after. For example, using a pattern of "MM/DD/YY" and the current date/time of Jan 1, 1997, the string "01/11/12" would be interpreted as Jan 11, 2012 while the string "05/04/64" would be interpreted as May 4, 1964. During parsing, only year strings consisting of exactly two digits, will be parsed into the default century. Any other numeric string, such as a one-digit string, a three- or more digit string, or a two-digit string that isn't all digits, is interpreted literally. So "01/02/3" or "01/02/003" are parsed, using the same pattern, as Jan 2, 3 AD. Likewise, "01/02/-3" is parsed as Jan 2, 4 BC. frevvo will always format as 4 digit years.  

Note

The date will be converted to the standard xsd:date format of yyyy-mm-dd in the submissions XML document. Here is an example: <Order Date>2012-03-06</Order Date>. Refer to Viewing XML Documents for more details.

Rules can be applied to the Date control in all variations.

Time Format

The Time Format property applies to the Time control type. The default, recommended format is "Automatic", which is a locale-specific time format. The designer has the option to set a particular time format independent of the locale by using the format field, but this is not recommended. Read this documentation for more information about time controls and internationalization.  

If you keep the default "Automatic" format, you can enter data into a Time control using any of the formats shown in the table. The Time control will accept and display the values as shown:  

Image Modified

The Time Format dropdown provides variations of military and standard time conventions, with either colon or period separators.

...

Note

The time will be converted to the standard xsd:time format of hh:mm:ss in the submissions XML document. Here is an example: <Order Time>14:00:00</Order Time>. Refer to Viewing XML Documents for more details.

...

Note

The local time will be converted to and saved in UTC format and the date will be converted to the standard xsd:datetime format of yyyy-mm-ddThh:mm:ssZ in the submission XML document. Here is an example: <OrderDate>2013-08-12T19:13:00Z</OrderDate>. Refer to Viewing XML Documents for more details. 

...

Similarly, if you have a date field with a default date in your form it must be formatted as YYYY-MM-DD in order for it to display correctly on mobile devices.


Tip

 recommends frevvo recommends enabling the date picker for forms that will be used on mobile devices to ensure the date is selected accurately.

...

Automatic Locale-Aware Format

 supports frevvo supports localization from the browser's locale setting.  will  frevvo will recognize the browser locale and alter displays and input formats as well as language according to the user's setting. Setting this preference is browser-specific. Refer to this website for information about language preferences and how to change those in a number of popular browsers. 

...

frevvo forms automatically infer the time zone from the user’s browser time zone. Once a form is loaded in a given time zone, that time zone cannot be changed.

Info

Review how  stores how frevvo stores Date, Time and Date/Time values in the submission document.

...

This example sets the controls "Today's Date" and "Today's Time" only once the user enters their name. Notice that the date and time are set in the user's time zone.

Image RemovedImage Added

Current Date and Time Functions Without Time Zone Context

...

Tip
titleBest Practice for Initializing Current Dates & Times in a Business Rule

If you plan to use a form.load rule to initialize a Date and/or Time control and want the value to resolve in a particular time zone (not UTC), you should provide the desired _formTz parameter in the share link or have your uses access the form from a  frevvo Space. Usually, you do not need _formTz when using Date/Time controls because Date/Time controls store data in UTC and display it in the user’s time zone.

...

Now let's try the exact same form with the _formTz parameter set to 'America/New_York'. Now you'll see that the Date and Time rules resolved to the current time in EDT, while the Date/Time rule resolved to the current time in UTC. However, they display exactly the same because the _formTz parameter overrides the user's browser time zone. This form would display exactly like this whether it was run in New York or in Paris.

Image RemovedImage Added

This table describes the difference between each rule function/control type when frevvo does or does not know the user's browser timezone.

Control Type:Date/TimeDateTime
Functions

frevvo.currentDateTime()

now()

frevvo.currentDate()

today()

frevvo.currentTime()

timeofday()

frevvo DOES know the browser time zone

  • Inside Space or Task List
  • or rules run on some condition other than initialization

Resolves to current time in UTC (Date/Time always stores value in UTC)                                                     

  •  '2021-08-03T15:53:07.436784Z'

Displays in User's browser time zone. A user in New York sees:           

  • 8/3/21 11:53 AM

Resolves to current date in User's browser time zone.

For a user in New York:

  • '2021-08-03'

Displays in User's browser time zone (e.g. New York). 

  • 8/3/21

Resolves to current time in User's browser time zone

For a user in New York:

  • '11:53:07'

Displays in User's browser time zone (e.g. New York).

  • 11:53 AM

Using the _formTz URL Parameter to define time zone

e.g. _formTz=America/New_York

Resolves to current time in UTC

  •  '2021-08-03T15:53:07.436784Z'

Displays in EST regardless of browser time zone

  • 8/3/21 11:53 AM

Resolves to current date in EST

  • '2021-08-03'

Displays in EST

  • 8/3/21

Resolves to current time in EST

  • '11:53:07'

Displays in EST

  • 11:53 AM


frevvo does NOT know the browser time zone

  • WITHOUT _formTz
  • and Outside of a Space or Task List
  • and rules run on initialization

Resolves to current time in UTC

  •  '2021-08-03T15:53:07.436784Z'

Displays in user's browser time zone, e.g. EST

  • 8/3/21 11:53 AM

Resolves to current date in UTC

  • '2021-08-03'

Displays in UTC

  • 8/3/2021

Resolves to current time in UTC

  • '15:53:07'

Displays in UTC

  • 3:53 PM

Correct Date and Time Formatting in Rules

 converts frevvo converts times into the browser's local timezone before displaying them in the form. However, if time data is not correctly formatted  will formatted frevvo will make multiple attempts to parse the time but will always display the time with NO timezone conversion. Here are examples of correct time formats:

...

This rule has incorrect UTC syntax. The Time control initialization is missing the required seconds and the date/time control is using an array syntax that is not a valid UTC time initializer.  makes  frevvo makes an attempt to parse the times and does fairly well in this case. But due to the incorrect syntax the date/time control's timezone is unknown and the rule is unable to do the proper conversion to the brower's timezone. The Time control's value is ok as it is not affected by timezone. The date/time control's value is clearly wrong as the browser is running in UTC-05:00 while August 23rd is in daylight savings time UTC-04:00. 

...

Excerpt
hiddentrue

This section is COPIED and PASTED from Working with Rules-DateandTimeMethods. If a change is made to one, please change the other to keep them in sync.

 provides frevvo provides built-in helper methods for common functionality required by business rules.

...

If these methods are used in rules, the designer will see a message in the Debug Console DebugConsole urging that the methods listed above DateandTimeMethods be used instead.

Note
titleBusiness Rules and Time Zones

Date and Time functions run in the context of a time zone. However, if your rules run before the form infers the browser time zone (on initialization and outside of a Space/Task List), these functions will return the server time in UTC. You should consider whether to add the _formTz parameter to specify the time zone where the rules should run. See the Time Zones and Business Rules documentation for more details.

...

Designers commonly use business rules to initialize the current date and the current time when a form loads, which ensures accurate data and saves the user one or two points of data entry. Here's a simple Contact Us form, which we want to initialize with the current date and time. We're using two Date controls, one is set to Control Type 'Date' and the other to Control Type 'Time'. Since we will prefill them using rules, we have removed decorators and the date picker and set them to disabled.

Image RemovedImage Added

Then we used the Visual Rule Builder to initialize the form with the Date and the Time.

Image RemovedImage Added

Now we're ready to share the form with users, so we need to decide whether or not to use the _formTz URL parameter in our Share link.

...

We can also choose to share this form inside a  a frevvo Space, which will automatically include the user's browser time zone in it's own _formTz parameter, and therefore the dates and times will resolve and display in the user's own time zone.

...