Hi @eosonwp,
One should be able to achieve this by adjusting the time zone but the shortcoming is that it won’t affect the client’s time zone. This best approach is to use custom functions for order dates. An example is in the code below:
function adjust_order_date_based_on_business_hours( $date ) {
$client_business_start_time = 0; // Midnight
$client_business_end_time = 2; // 2AM
$current_time = current_time( 'timestamp' );
// Check if the current time is between midnight and 2am
if ( date( 'H', $current_time ) >= $client_business_start_time && date( 'H', $current_time ) < $client_business_end_time ) {
// Adjust the date to the previous day
$date = date( 'Y-m-d H:i:s', strtotime( '-1 day', strtotime( $date ) ) );
}
return $date;
}
add_filter( 'woocommerce_order_get_date_created', 'adjust_order_date_based_on_business_hours' );
The code adjusts the order date for nay orders created between midnight and 2am, making them count under the previous day.
An alternative no code option is to use custom reporting plugin that allows adjusting timezones. Please note that providing code support is outside the support scope of the forum. The code above is just to give you an idea of what is possible. If you need help getting this done, it is best to hire an expert.