Businesses have deadlines!
Magento 2 stores are no exceptions.
There are multiple times when you need to add time control in Magento 2 store.
For instance, when you launch offers, you have to set the cut off time for ending the offers. By using time control in admin configuration, you can manage when the offer will end and the prices will set back to normal.
Or, managing the timelines for order delivery and payments can be easy using the timer.
You can use the below solution to add time control in admin configuration using system.xml file in Magento 2. along with your custom code.
Solution to Add Time Control in Admin Configuration using system.xml File in Magento 2

To set as shown above, you need to follow these three steps;
Step 1:
Create registration.php file at app\code\Vendor\Module directory
<?php use \Magento\Framework\Component\ComponentRegistrar; ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Vendor_Module', __DIR__);
Step 2:
Create module.xml file at app\code\Vendor\Module\etc directory
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> <module name="Vendor_Module" setup_version="1.0.0"/> </config>
Step 3:
Create system.xml file at app\code\Vendor\Module\etc\adminhtml directory
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd"> <system> <tab id="extension_name" translate="label" class="extension_name" sortOrder="100"> <label></label> </tab> <section id="section_id" translate="label" type="text" sortOrder="320" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Example</label> <tab>extension_name</tab> <resource>Vendor_Module::module_name</resource> <group id="general" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1"> <label>General</label> <field id="enable" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Enable</label> <source_model>Magento\Config\Model\Config\Source\Enabledisable</source_model> </field> <field id="cutofftime" translate="cut off time" type="time" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Cut off Time</label> </field> </group> </section> </system> </config>
Done! You are good to go.
Do not forget to share this post with Magento Community via social media.
Thank you.