We display event dates/times via Wordpress date and time functions in am/pm time (12 hour, not 24 hour). For any times that are noon - i.e. "12:00 pm" - we'd like to display "12:00 noon" instead.
And we'd also like to display "12:00 midnight" instead of "12:00 am".
This is to avoid confusion (we run online events around the world at different times so there is room for this type of confusion).
All other times of the day can keep their am/pm, it's just these two exact times that we're seeking to change.
We display event dates/times via Wordpress date and time functions in am/pm time (12 hour, not 24 hour). For any times that are noon - i.e. "12:00 pm" - we'd like to display "12:00 noon" instead.
And we'd also like to display "12:00 midnight" instead of "12:00 am".
This is to avoid confusion (we run online events around the world at different times so there is room for this type of confusion).
All other times of the day can keep their am/pm, it's just these two exact times that we're seeking to change.
Share Improve this question asked Apr 21, 2020 at 13:04 JulianJulian 981 silver badge8 bronze badges 7 | Show 2 more comments2 Answers
Reset to default 2So what you need to do is make your life easier and instead of searching everything within every instance of .pp-post-content
or .pp-post-content p
, let's wrap the times or the times in question with a span tag. Like you suggested in your comments <span class="tas-event-time">
is sufficient enough.
Now, in your .js file, you want to add the following:
jQuery( document ).ready( function($) {
$( '.tas-event-time' ).html( $( '.tas-event-time' ).html().replace( '12:00 pm','12:00 noon') );
} );
That will, once the document is ready, change the instances of '12:00 pm' to '12:00 noon'.
I think you can Do it with Translation loops! Simply find the "12:00 pm" and put 12:00 Noon. Maybe It works! try it :D.
am
andpm
using jQuery - can you post your output code so we can see if there's something that can be targeted via the functionality? I've done something similar by replacing 'months' with 'seasons' but you have to be able to target an element and replace the text. – Tony Djukic Commented Apr 21, 2020 at 13:19<span class="pp-time">12:00 pm</span>
? – Tony Djukic Commented Apr 21, 2020 at 14:28$(".tas-event-time").text(function () { return $(this).text().replace("pm", "noon"); });
– Julian Commented Apr 21, 2020 at 14:47pm
instances though, just those that start at 12:00, correct? – Tony Djukic Commented Apr 21, 2020 at 14:49