WordPress: How to Display Date and Time with User-preferred Formatting

We set Date Format and Time Format in WordPress General Setting and we want to display that date on WordPress template. The Date Format and the Time Format settings allow us to set Date and Time to any format we wants, it also easier to use with localization. Use following code in WordPress template

<?php the_time(get_option('date_format')); ?>


<?php the_time(get_option('time_format')); ?>