[wp-trac] [WordPress Trac] #57683: Improve performance of mysql2date
WordPress Trac
noreply at wordpress.org
Thu Mar 9 11:44:58 UTC 2023
#57683: Improve performance of mysql2date
--------------------------+-----------------------------
Reporter: spacedmonkey | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Future Release
Component: Date/Time | Version: 0.71
Severity: normal | Resolution:
Keywords: has-patch | Focuses: performance
--------------------------+-----------------------------
Comment (by spacedmonkey):
@Rarst Sorry, I am really confused here.
[https://core.trac.wordpress.org/ticket/57683#comment:14 Here] you say it
important we pass handle the timezone. I do that and add caching, you then
you suggest [https://core.trac.wordpress.org/ticket/57683#comment:15 here]
solutions that ignore timezone completely. Which is it?
To be clear the performance issue, is calling `wp_timezone` so many times
on a single page load. it has an overhead, I am trying to avoid here.
Caching it and reusing it within the same WP_Query instance, makes sense
to me. If you have a filter that runs on the get_option, it will fire the
first time and not again. There is no need let the filters run every time,
it is unlikely to change and just wasteful.
My preferred solution is still this.
{{{#!php
$post_date = date_create( $post->post_date );
if ( ! $post_date ) {
$currentday = false;
$currentmonth = false;
} else {
$currentday = $post_date->format( 'd.m.y' );
$currentmonth = $post_date->format( 'm' );
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57683#comment:19>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list