Handling Dates and Time
The dates you deal with most of the time are related to the restaurant's timezone. To display and handle dates and times correctly we implemented some tools that make it easy to do this in the right way.
Displaying dates and time
To display dates and time the best solution is to use the react-intl package.
The portal exposes it so you can define it as an external package. This has the advantage that the FormattedDate and
FormattedTime components directly display the dates and time in the right timezone. If you need to display a time in
a different timezone, you can override the timeZone in the components yourself.
Handling other dates
You often need dates for something for other than display (e.g. for API call from/to arguments or for a date selector input). For this our SDK gives you some tools:
- Pre-formatted date and time strings:
getRestaurantDateString(date)getRestaurantTimeString(date)getRestaurantTimeStringWithSeconds(date)
- Date parts:
getRestaurantDateParts(date)
These methods return the date in the restaurant timezone, so the device does not need to be in the same timezone. For more information about these methods see the SDK documentation.