Functions
/
Time and Date Handling
Getting Started
Tutorials
Datasources
Functions
Spaces
Components
Self Hosted
Settings

Time and Date Handling

Types

When internal.io connects to a datasource, like a Postgres database, and generates Functions for interacting with it, internal.io analyzes how the data is structured and creates representations that are used for reading and writing the data. Part of these representations include how internal.io categorizes the types of data it discovers. In the Postgres database example, internal.io inspects the types of each column in each table and creates Function Attributes and Parameters that in part map those postgres specific data types to internal.io’s type system.

In this section we’re going to be focusing on how internal.io represents and interacts with the dates and times it encounters in your data.

Internal.io date and time types

  • Date - a date with no timezone information such as “2021-01-01”
  • Time  - a time with no timezone and no date information such as “23:00”
  • Datetime - a date and time with no timezone information such as “2021-01-01 02:00:00.000”
  • Timestamp - a date and time with a timezone represented as an offset from UTC time such as “2021-01-01 23:00:00:00.000-7:00”
  • unix Timestamp - presented in milliseconds

Displaying dates and times

Timestamps

When internal.io displays timestamp data to a user it is converted from the timezone defined by the timezone offset in the timestamp data to the user’s local timezone. The user’s local timezone is inferred from their web browser (in all modern browsers this is determined using the Internationalization API, but more details are available here: https://momentjs.com/timezone/docs/#/using-timezones/guessing-user-timezone/). So if a timestamp is in UTC time and the user is in PST time, internal.io will display the timestamp to them in PST, adjusting the date and time as necessary. 

As Inputs/Parameters in Functions

If a user submits a timezone field with current date/time, Internal will pass the date/time with offset from UTC on form submit. Their service will determine how to store it (set to db default; e.g. PostgreSQL stores the timestamp with offset).

If no timezone is specified, Internal will pass the date/time info without the offset: the local date/time, with no offset indicating the timezone.

In Published Spaces

Internal renders the offset (as the timezone) based on the time value from the DB

Custom DateTime

Dates that are displayed in components such as Table, Card List, and Detail can be formatted for display. There are a number of common date and time formats to select from and a custom option if none of those meet your needs. The following table defines the tokens available for custom date and time formatting:


In edit mode, select the field which you wish to customize and select "Date/Time Format," scroll to the bottom of the configuration dropdown and select "custom." From there, you can use the table below to format that data.

Note: The following table is extracted from Moment.js' API documentation.

Token Output
Month M 1 2 ... 11 12
Mo 1st 2nd ... 11th 12th
MM 01 02 ... 11 12
MMM Jan Feb ... Nov Dec
MMMM January February ... November December
Quarter Q 1 2 3 4
Qo 1st 2nd 3rd 4th
Day of Month D 1 2 ... 30 31
Do 1st 2nd ... 30th 31st
DD 01 02 ... 30 31
Day of Year DDD 1 2 ... 364 365
DDDo 1st 2nd ... 364th 365th
DDDD 001 002 ... 364 365
Day of Week d 0 1 ... 5 6
do 0th 1st ... 5th 6th
dd Su Mo ... Fr Sa
ddd Sun Mon ... Fri Sat
dddd Sunday Monday ... Friday Saturday
Day of Week (Locale) e 0 1 ... 5 6
Day of Week (ISO) E 1 2 ... 6 7
Week of Year w 1 2 ... 52 53
wo 1st 2nd ... 52nd 53rd
ww 01 02 ... 52 53
Week of Year (ISO) W 1 2 ... 52 53
Wo 1st 2nd ... 52nd 53rd
WW 01 02 ... 52 53
Year YY 70 71 ... 29 30
YYYY 1970 1971 ... 2029 2030
YYYYYY -001970 -001971 ... +001907 +001971
Note: Expanded Years (Covering the full time value range of approximately 273,790 years forward or backward from 01 January, 1970)
Y 1970 1971 ... 9999 +10000 +10001
Note: This complies with the ISO 8601 standard for dates past the year 9999
Era Year y 1 2 ... 2020 ...
Era N, NN, NNN BC AD
Note: Abbr era name
NNNN Before Christ, Anno Domini
Note: Full era name
NNNNN BC AD
Note: Narrow era name
Week Year gg 70 71 ... 29 30
gggg 1970 1971 ... 2029 2030
Week Year (ISO) GG 70 71 ... 29 30
GGGG 1970 1971 ... 2029 2030
AM/PM A AM PM
a am pm
Hour H 0 1 ... 22 23
HH 00 01 ... 22 23
h 1 2 ... 11 12
hh 01 02 ... 11 12
k 1 2 ... 23 24
kk 01 02 ... 23 24
Minute m 0 1 ... 58 59
mm 00 01 ... 58 59
Second s 0 1 ... 58 59
ss 00 01 ... 58 59
Fractional Second S 0 1 ... 8 9
SS 00 01 ... 98 99
SSS 000 001 ... 998 999
SSSS ... SSSSSSSSS 000[0..] 001[0..] ... 998[0..] 999[0..]
Time Zone z or zz EST CST ... MST PST
Note: as of 1.6.0, the z/zz format tokens have been deprecated from plain moment objects. Read more about it here. However, they *do* work if you are using a specific time zone with the moment-timezone addon.
Z -07:00 -06:00 ... +06:00 +07:00
ZZ -0700 -0600 ... +0600 +0700
Unix Timestamp X 1360013296
Unix Millisecond Timestamp x 1360013296123

Writing dates and times

Timestamps

Existing values

As noted above, when internal.io displays timestamp data to a user that date and time is presented in the user’s local timezone. Similarly when making edits the date and time is presented in the user’s local timezone. If that edited timestamp is written back to the datasource, the timestamp is written to the datasource using UTC’s time zone offset. For example if a user is editing a timestamp that is stored with an EST offset and that user’s local timezone is PST, the user will see the timestamp presented in PST and be able to edit it in PST, but when it is written back to the datasource it is converted to UTC.

New values

New timezone values are written using the UTC timezone offset.

Other date and time types

Date and time values without timezone information are presented to the user unchanged and are assumed to be in the user’s local time. Similarly they are written to their datasource as entered by the user with no timezone conversion and with no timezone information.