Skip to main content

Datetime

The value must be a valid date-time.

Parameter table​

paramunitrequireddescription
keyyesThe key of the value to check if it is a valid date-time.
formatnoThe format of the date-time.

How to setup​

The rule verifies whether the value of the specified key (key) is a valid date-time. The value is considered valid if it is a string that can be parsed into a date-time. An optional parameter (format) can be adjusted to enforce a certain format. In such a case, the value will pass the check if it can be parsed into a date-time in the specified format. To further check the formats you can take a look at the moment.js documentation.

The rule can also be used to validate timestamps if you need to represent a moment in milliseconds since the Unix Epoch (Jan 1 1970 12AM UTC).

Note: It is recommended to specify the format of the date-time to avoid ambiguity. Additionally, browser support for parsing strings is inconsistent because there are no specifications about which formats should be supported as what works in some browsers might not in others.

Examples​

valuevalidformatdescription
2020-12-31T23:59:59.999Z✅The value is a valid date-time.
2020-12-31T23:79:59❌The value is not a valid date-time.
2020-12-31❌YYYY-MM-DDTHH:mm:ss.SSSZThe value is not a valid date-time in the specified format
2020-12-31T23:59:59.999Z✅YYYY-MM-DDTHH:mm:ss.SSSZThe value is a valid date-time in the specified format
1609459199✅The value is a valid timestamp (number of milliseconds since the Unix Epoch).