magento2 – Magento 2: how to add a date filter to the new product widget

I'm using a new product widget in my custom phtml template. It shows the new products. but I want to add the date filter to these products. How can I do it. Any help appreciated.

template file code:

getLayout () -> createBlock ("Magento  Catalog  Product  Widget  NewWidget") -> setDisplayType ("new_products") -> setProductsCount ("20") -> setTemplate ("product / widget / new / content / new_grid. phtml ") -> toHtml (); ?>

I've added fields from and to date in product / widget / new / content / new_grid.phtml but I do not know how to pass these dates to work and get filtered results. Thanks in advance. Any help appreciated.