My client want to offline the site for 12:00 AM to 06:00 AM and show this message to users. How can I achieve this in drupal8
and welcome to StackExchange.
As stated in the comments on your question, you are essentially asking for Maintenance Mode, which is part of Drupal core. In your site, go to
/admin/config/development/maintenance and look at the settings there. You can turn on Maintenance mode, and set the text that is shown to unauthorized users. There is also a permission setting (found on the permissions page) to still use the site in maintenance mode, in case you want to make edits while others cannot access the site.
To have this happen automatically based on time, you will want to use Cron. That is what Cron was built to do, so it is a perfect fit. In order to use Cron for this, you will need a handy bit of code that can do the same thing as the checkbox in the maintenance ui. Drush is a very powerful tool, and can do almost anything. To turn maintenance mode on, you could run this:
drush state:set system.maintenance_mode 1 --input-format=integer
That command is found and explained on this page. Now, you need to have that command run by cron instead of by a human on the server command line. Fortunately for you, Drupal has a long history of dynamically using custom code that you add, as long as the name matches. That is the hook system, where custom modules and functions matching certain patterns are called at certain times. You will want to create a custom module that uses hook_cron() to run that drush command at the designated times.
And finally, always clear cache before thinking something is broken.