Introduction
When customizing the form with the help of SPFx, we may come across the requirement of using Date Time control. However, if we are using fluent UI react controls, formally known as Office UI fabric React controls, then we do not have control with both date and time. Rather, we only have date picker to overcome this PnP Team has created a DateTimePicker Control this can be easily used and configured in SPFx. To know how we can use it, let's see the step-by-step guide.
Step 1 - Create an SPFx Solution
To create an SPFx solution, we are required to have nodejs v10.x installed. Along with that, we are required to have yeoman and gulp installed and SharePoint framework yeoman generator. Once the environment is ready, we can create a new solution to create a new solution using the below command:
yo @microsoft/sharepoint
After running the above command, we are presented with multiple questions which we can provide values to, as mentioned in the image below.

Step 2 - Add reference of PnP SPFx Controls
To add the reference to the solution for the controls, we can use the below command by adding the reference of PnP SPFx controls we can use many controls which are available. To check all the controls, use the below link.
https://pnp.github.io/sp-dev-fx-controls-react/#available-controls
npm install @pnp/spfx-controls-react --save --save-exact

Step 3 - Update the code
Now let's use the control in our Web part. Open the file name SamplePnPDateTimePickerWebpart.tsx
To add a reference to the control, use the below import statement:
- import { DateTimePicker, DateConvention, TimeConvention, TimeDisplayControlType } from '@pnp/spfx-controls-react/lib/dateTimePicker';


Join the conversation! Your thoughts help the community grow.