How to adjust meta value to UTC time in WP Query
How to adjust meta value to UTC time in WP Query
How to adjust meta value to UTC time in WP Query
Apologies for the off-topic question. I found the answer on StackOverflow, it’s a PHP question not specific to WordPress. The following code changes the format as required. From https://stackoverflow.com/questions/2487921/convert-a-date-format-in-php <?php $new_checkin = date(‘jS F Y’, strtotime($checkin)); ?> <?php echo esc_html( $new_checkin ); ?>
I managed to find the solution myself. You need to modify the onUpdateStartDate() function: function onUpdateStartDate(value) { const date = new Date(value); date.setHours(0, 0, 0, 0); setMeta({ …meta, ‘_my_start_date’: date }); }
If your posts store the date in a consistent format like YYYY-MM-DD HH:MM:SS, etc, you could compare with strings using regular expressions, like: $current_date = new DateTime(); $datemonth = $current_date->format(“m-d”); // MM-DD $args = array( // … ‘meta_query’ => array( array( ‘key’ => ‘birthday’, ‘compare’ => ‘REGEXP’, // Regular expression explanation: // ^ – Start … Read more
Use the parameters of the shortcode with lowercase: [recurring_event short=”Wed” full=”wednesday”] Try to follow the next code: // NAV: Custom Code function wpcoder_recurring_event_att( $atts ){ $date=””; $default = array( ‘short’ => ‘Sun’, ‘full’ => ‘sunday’ ); $eventday = shortcode_atts($default, $atts); date_default_timezone_set(‘US/Eastern’); if(date(‘D’) == $eventday[“short”]) { echo date(‘F d, Y’); } else { // Create a … Read more
What you did wrong here is the part date(‘d’, $rem_days). The function date() should be used to convert timestamp to a formatted date, not to converting a time difference in timestamp to time difference in days. You can fix this by replacing date(‘d’, $rem_days) with floor($rem_days/86400). The complete code should be: $event_date = strtotime( get_field( … Read more
The issue here is that you’re trying to match the post_date exactly with $order_date. However, post_date is a datetime field and includes the time as well, so it’s unlikely to match exactly with a date string like ‘2023-02-28’. If you want to get orders by month, you can use the MySQL MONTH() and YEAR() functions … Read more
WP_Query filtering in ACF field containing dates
How to display only posts from the last day with posts published?
I settled on using wp_cache_set and wp_cache_get which seems to do well. I create a key based on the class, function, and parameters: $cacheKey = self::createCacheKey( __CLASS__, __FUNCTION__, $referenceYear, $referenceMonth ); createCacheKey() looks like: protected static function createCacheKey( …$args ): string { return implode(‘-‘, $args); } And I’m sure to use an appropriate expiration. For … Read more