{"id":1361,"date":"2020-11-13T11:11:32","date_gmt":"2020-11-13T11:11:32","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/2020\/11\/13\/add-time-control-in-admin-configuration-using-system-xml-file-in-magento-2\/"},"modified":"2025-05-22T11:32:30","modified_gmt":"2025-05-22T06:02:30","slug":"add-time-control-in-admin-configuration-using-system-xml-file-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/add-time-control-in-admin-configuration-using-system-xml-file-in-magento-2\/","title":{"rendered":"How to Add Time Control in Admin Configuration Using System.xml File in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Businesses have deadlines!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Magento 2 stores are no exceptions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There are multiple times when you need to add time control in Magento 2 store.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Or, managing the timelines for order delivery and payments can be easy using the timer.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can use the below solution to&nbsp;<strong><em>add time control in admin configuration using system.xml file in Magento 2<\/em><\/strong>. along with your custom code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Solution to Add Time Control in Admin Configuration using system.xml File in Magento 2<\/h2>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2020\/11\/Annotation-on-2020-11-05-at-11-50-16.png\" alt=\"Add Time Control in Admin Configuration using system.xml File in Magento 2\" class=\"wp-image-11486\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">To set as shown above, you need to follow these three steps;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1:<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create&nbsp;<strong>registration.php<\/strong>&nbsp;file at&nbsp;<strong><em><strong><em>app\\code\\Vendor\\Module directory<\/em><\/strong><\/em><\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nuse \\Magento\\Framework\\Component\\ComponentRegistrar;\n\nComponentRegistrar::register(ComponentRegistrar::MODULE, 'Vendor_Module', __DIR__);<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2:<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create&nbsp;<strong>module.xml<\/strong>&nbsp;file at&nbsp;<strong><em><strong><em>app\\code\\Vendor\\Module\\etc directory<\/em><\/strong><\/em><\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?xml version=\"1.0\"?>\n&lt;config xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n        xsi:noNamespaceSchemaLocation=\"urn:magento:framework:Module\/etc\/module.xsd\">\n    &lt;module name=\"Vendor_Module\" setup_version=\"1.0.0\"\/>\n&lt;\/config><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3:<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create&nbsp;<strong>system.xml<\/strong>&nbsp;file at&nbsp;<strong><em><strong><em>app\\code\\Vendor\\Module\\etc\\adminhtml directory<\/em><\/strong><\/em><\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?xml version=\"1.0\"?>\n&lt;config xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n        xsi:noNamespaceSchemaLocation=\"urn:magento:module:Magento_Config:etc\/system_file.xsd\">\n    &lt;system>\n        &lt;tab id=\"extension_name\" translate=\"label\" class=\"extension_name\" sortOrder=\"100\">\n            &lt;label>&lt;\/label>\n        &lt;\/tab>\n        &lt;section id=\"section_id\" translate=\"label\" type=\"text\" sortOrder=\"320\" showInDefault=\"1\" showInWebsite=\"1\"\n                 showInStore=\"1\">\n            &lt;label>Example&lt;\/label>\n            &lt;tab>extension_name&lt;\/tab>\n            &lt;resource>Vendor_Module::module_name&lt;\/resource>\n            &lt;group id=\"general\" translate=\"label\" type=\"text\" sortOrder=\"1\" showInDefault=\"1\" showInWebsite=\"1\"\n                   showInStore=\"1\">\n                &lt;label>General&lt;\/label>\n                &lt;field id=\"enable\" translate=\"label\" type=\"select\" sortOrder=\"1\" showInDefault=\"1\" showInWebsite=\"1\"\n                       showInStore=\"1\">\n                    &lt;label>Enable&lt;\/label>\n                    &lt;source_model>Magento\\Config\\Model\\Config\\Source\\Enabledisable&lt;\/source_model>\n                &lt;\/field>\n                &lt;field id=\"cutofftime\" translate=\"cut off time\" type=\"time\" sortOrder=\"4\" showInDefault=\"1\"\n                       showInWebsite=\"1\"\n                       showInStore=\"1\">\n                    &lt;label>Cut off Time&lt;\/label>\n                &lt;\/field>\n            &lt;\/group>\n        &lt;\/section>\n    &lt;\/system>\n&lt;\/config><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Done! You are good to go.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Do not forget to share this post with Magento Community via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-1361","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1361","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=1361"}],"version-history":[{"count":4,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1361\/revisions"}],"predecessor-version":[{"id":14621,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1361\/revisions\/14621"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1361"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1361"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1361"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}