FormattedDateTime
Reference
- The
FormattedDateTimecomponent is used to display formatted date-time or time strings. - It formats and displays a date/time string with the specified date/time zone
Components and Props:
-
FormattedDateTime:- Props:
dateTimeStr: A string representing the date-time to be formatted.style: An optional inline style object for customizing the<span>appearance.isUtcTimeZone: A boolean (default:false) to determine if the date-time should be formatted in UTC (+00:00) or the local UTC offset.
- Usage: Formats and displays a date-time string with the specified time zone.
- Props:
-
FormattedTime:- Props:
timeStr: A string representing the time to be formatted.style: An optional inline style object for customizing the<span>appearance.
- Usage: Formats and displays a time string based on the global time format and UTC offset.
- Props:
- Both components return a
<span>element containing the formatted value, styled using the optionalstyleprop.
Usage Example
function Example(pageContext) {
const { protrakComponents } = React.useContext(customWidgetContext);
const { FormattedDateTime } = protrakComponents;
return (
<div>
<H3>Date along with Time</H3>
<FormattedDateTime dateTimeStr="2025-04-07T11:44:34.263Z" />
<div/>
);
};