Ask the community

This is a community support forum where you can ask
questions and interact with other PremiumPress Customers.

days open hours is showing military time instead of normal time. how to change?

  • mark
    mark
    Senior Member 168 points
    July 11, 2019 at 3:31 pm

    how do i change this to show regular hours instead of military time? thanks!

    Attachments:
    You must be logged in to view attached files.
  • JamesD
    JamesD
    Super Guru 1,345 points
    July 11, 2019 at 10:31 pm

    Hello mark,
    To do this would require editing two core files, which wouldn’t be ideal since this cannot be done within the child theme. The files would be overwritten by the next update. Only other option would be via javascript, which wouldn’t really be ideal either.

  • JamesD
    JamesD
    Super Guru 1,345 points
    July 12, 2019 at 4:12 am

    @mark

    Here is a way you could at least change it on the website listing using the child theme method:
    In your child theme directory create a folder called widgets.

    Place a copy of /DT9/_directory/widgets/widget-openinghours.php into this directory.
    Now, open the the widget-openinghours.php and replace line #115:

    <span><?php echo date('H:i A', strtotime($bh['start'][$i])); ?> - <?php echo date('H:i A', strtotime($bh['end'][$i])); ?></span>

    With

    <span><?php echo date('h:i A', strtotime($bh['start'][$i])); ?> - <?php echo date('h:i A', strtotime($bh['end'][$i])); ?></span>

    Next we need to change the path to call the child theme widgets/widget-openinghours.php file instead of the default.

    Place a copy of /DT9/_directory/single-listing.php into your child theme directory (if the file doesn’t already exist).

    Open the single-listing.php file and replace line #51:

    <?php get_template_part( '_directory/widgets/widget', 'openinghours' );  ?>

    With

    <?php get_template_part( 'widgets/widget', 'openinghours' );  ?>

    Those steps should change the display on the listings to a 12 hour format without altering any core files.

    Note: Formatting can be changed where you see the date function with the settings like h:i A. Capital ‘H’ is the 24 hour format while small ‘h’ is 12 hour format. More formatting details can be found HERE.

    Haven’t found a good way to handle the changes within the adding/editing listing form. That code is in the functions.php file.

  • mark
    mark
    Senior Member 168 points
    July 12, 2019 at 6:40 pm

    Thank you jamesd but we dont be doing this. Beyond comfort level and I am on a deadline that is fast approaching. many thanks as usual though! mark:-)

  • JamesD
    JamesD
    Super Guru 1,345 points
    July 13, 2019 at 12:06 am

    @mark
    Ok, I gotcha.

    Would it be any help if I put the edited files in a zip file where all you would need to do is unzip it, upload the contents directly into your child theme directory or would that not be ideal for your situation?

    Note: The directories I mentioned, that would need to be created, would already be included. Uploading the contents would be the only thing to do. However, don’t forget as stated previously, this would only impact the actual listing page view hours, not the settings within the listings.

Viewing 5 posts - 1 through 5 (of 5 total)